Re: [R] Generating repeated measures data

From: Joshua Wiley <jwiley.psych_at_gmail.com>
Date: Fri, 18 Mar 2011 17:58:36 -0700

Hi John,

This is not advanced enough for serious applications, but if you are just looking for a simple way to make example data, you could do something like:

gencor <- function(order, mu, sd, r) {
  X <- matrix(rnorm(prod(order), mean = mu, sd = sd), nrow = order[1], ncol = order[2])
  R <- matrix(r, nrow = order[2], ncol = order[2])   diag(R) <- 1
  X %*% chol(R)
}

cor(X <- gencor(c(100, 3), 10, 2, .5))

HTH, Josh

On Fri, Mar 18, 2011 at 5:37 PM, John Sorkin <jsorkin_at_grecc.umaryland.edu> wrote:
> How would one generate data to be used in a simulation of a repeated measures ANOVA given a known (1) within-person correlation with known (2) mean and SD of data obtained at each of three times of observation?
> Thanks,
> John
> John Sorkin
> Chief Biostatistics and Informatics
> Univ. of Maryland School of Medicine
> Division of Gerontology and Geriatric Medicine
> JSorkin_at_grecc.umaryland.edu
> Confidentiality Statement:
> This email message, including any attachments, is for ...{{dropped:17}}



R-help_at_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. Received on Sat 19 Mar 2011 - 01:01:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 19 Mar 2011 - 01:10:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive