i´m really sorry, once again. ok i will try to explain what i have to programm. i want to programm a powerfunction. i have to research if the correlations in a bivariate random sample are homogeneous. for that i saperate the random sample in m blocks and calculate the correlation of each block(partial sample). than i look at the random variable p=cor(x1,y1)^2/sum(cor(x,y)^2) which is a probability. my null hypothesis is that all correlations are homogeneous. if we have this situation the entropy take the value log(m). my test based on the entropy. so my teststatic is H=log(m)-sum(p*log(p)). the following programm was actually, which i have worked the most of the time. i hope that i don´t confuse u too much. i of course i hope u understand my problem and my theme. n=1000 m=2 k=n/m N=100 myfun <- function(n, m, alpha = .05, seeder = 1000) { l=matrix(0,nrow=m,ncol=N) for(i in 1:N){ set.seed(i) for(j in 1:m){ x=rnorm(n,0,0.5) y=rnorm(n,0,0.8) l[j,i]=cor((x[(((j-1)*k)+1):(((j-1)*k)+k)]), (y[(((j-1)*k)+1):(((j-1)*k)+k)])) } }
gute <- function(x,m) { q_1 <- qnorm(alpha, 0, 0.05) q_2 <- qnorm(1 - alpha, 0, 0.05) p=matrix(0,nrow=m,ncol=N) H=matrix(0,nrow=N,ncol=1) for(i in 1:N){ for (j in 1:m){ p[j,i]=x[j]^2/sum(x[,i]^2) } H[i]=log(m)-sum(p[,i]*log(p[,i])) } 1 - mean(q_1 <= H & H <= q_2) } output <- gute(x = l,m=m) return(output) } -- View this message in context: http://r.789695.n4.nabble.com/the-function-doesn-t-work-tp2714105p2714137.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.