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 th...{{dropped:6}}
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}}
At 00:37 19/03/2011, John Sorkin 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?You do not say which distribution you want them to have but for normal the best choice seems to be to load MASS and use rmvtnorm. Generating multivariate datasets from distributions other than the normal can be more challenging. In \R contributed packages provide the following among others: \begin{description} \item[\pkg{corcount}] Poisson, negative binomial, zero--inflated versions \item[\pkg{binarySimCLF}] Generates binary variables, see \citet{qaqish03} for details \item[\pkg{bindat}] Generates binary by thresholding normal \item[\pkg{mvtBinaryEP}] Binary \item[\pkg{sn}] Skew normal and skew $t$ \end{description} Apologies for all the LaTeX but I fear if I try to edit it I will delete something crucial.>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 t...{{dropped:6}}
hi i checked the package "corcounts", but it seems to be used for generating high dimensional correlated count data. is it also proper for generating data with N=50 for instance? thanks -- View this message in context: http://r.789695.n4.nabble.com/Generating-repeated-measures-data-tp3388807p4409373.html Sent from the R help mailing list archive at Nabble.com.