Skip to content
Back to formatted view

Raw Message

Message-ID: <1305553368781-3526231.post@n4.nabble.com>
Date: 2011-05-16T13:42:48Z
From: Holger Steinmetz
Subject: 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])
    }

Goal: The 10 correlations shall be contained in the r-vector.
However, this does not work. I get an error that "arguments do not match"

Has anybody an idea?

Best,
Holger



--
View this message in context: http://r.789695.n4.nabble.com/Simulating-correlations-with-varying-sample-sizes-tp3526231p3526231.html
Sent from the R help mailing list archive at Nabble.com.