Hi Holger,

Replace "N" by "N[i]".

HTH,
Jorge


On Mon, May 16, 2011 at 9:42 AM, Holger Steinmetz <> wrote:

> 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.
>
> ______________________________________________
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to