search for: corrfun

Displaying 1 result from an estimated 1 matches for "corrfun".

Did you mean: corfun
2011 May 16
3
Simulating correlations with varying sample sizes
Hi there, I would like to draw 10 correlations from a bivariate population - but every draw should be done with a different sample size. I thought I could to this with a loop: r=numeric(10) #Goal vector N = c(1000,100,80,250,125,375,90,211,160,540) #Sample size vector for(i in 1:10) { data <- mvrnorm(n=N,mu=c(0,0),Sigma=matrix(c(1,.3,.3,1),2)) r[i] <- cor(data[,1],data[,2]) }