[R] the function doesn´t work

jethi kartija at hotmail.com
Sun Sep 26 08:39:29 CEST 2010


hey, my function doesn´t work. can somebody help me?
the graphic doesn´t work and also the function. thnx a lot.

N=10
n=100

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

power = function(p,m) {
set.seed(1000)
H=matrix(0,nrow=N,ncol=1)
for(i in 1:N) {
 x <- matrix(rnorm(n, 0, 0.5), ncol = m)
 y <- matrix(rnorm(n, 0, 0.8), ncol = m)
 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)
}
m=seq(10,50,len=10)
f=outer(p,m,Vectorize(power))
persp(p,m,power,theta=-50,phi=30,d=4,border="black")
-- 
View this message in context: http://r.789695.n4.nabble.com/the-function-doesn-t-work-tp2714105p2714105.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list