[R] the function doesn´t work

jethi kartija at hotmail.com
Sun Sep 26 09:28:41 CEST 2010


hi, sorry but i can´t remove the problem.but i change the programm a little
bit. i didn´t work with r programm before, so its really hard for me to find
my problems. :) 


N=5
n=100


p_0=c(1/5,1-1/5)

power = function(k1) {
set.seed(1000)
H=matrix(0,nrow=N,ncol=1)

for(i in 1:N) {

 x <- matrix(rnorm(n, 0, 0.5), ncol =m1)
 y <- matrix(rnorm(n, 0, 0.8), ncol = m1)
 l <- diag(cor(x, y))



q_1 = qnorm(0.05, 0, 0.05)
   q_2 = qnorm(1 - 0.05, 0, 0.05)
p <- (l^2)/sum(l^2)

H[i] <- sum(p_0*log(p_0))  - sum(p * log(p))

}
1- mean(q_1 <= H & H <= q_2)

}
m1=seq(0,n/2,len=10)
k1=1/m1
output <- power(k1)
f=outer(k1,Vectorize(power))
-- 
View this message in context: http://r.789695.n4.nabble.com/the-function-doesn-t-work-tp2714105p2714123.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list