mercredi 3 octobre 2018

Generate multivariate normal data with unequal sample sizes

I would like to generate multivariate random data manipulating the sample size and variance using MASS::mvrnorm (or, as the case may prove to be, rnorm). This is fairly straightforward, however, the trick is that I intend to simulate a statistic with this generated data that compares two different sample sizes (of different lengths). Essentially, this creates a 3X3 design where I have three levels of 2 different sample sizes (e.g. [450,150], [300,300], [150,450]) crossed with three levels of variance (e.g. [1,1], [1,3], [1,10]).

    n <- c(450,150,300,300,150,450) # sample sizes

    sig <- matrix(c(1,1,1,3,1,10), nrow=2, byrow=F) # variance

    mu <- (5, 5, 5) # mean is constant across all conditions 

    mvrnorm(n, mu, sig) 

I'm sure that I have to iterate through my vector of sample sizes, just as I would if I were only generating one sample size per condition. But since I'm generating two sample sizes for each condition, I am unsure how to do this.




Aucun commentaire:

Enregistrer un commentaire