peter_petersen
2010-Dec-09 15:49 UTC
[R] Mixed Model analysis instead of repeated measures ANOVA: how to call lmer or lme instead of aov?
Dear R Community! I try to detect differences in the the reaction times of different experimental conditions. The treatment has three levels and was manipulated within each subject. Each subject is tested e.g. 100 times for each treatment. Usually, in psychophysics, data like this is analyzed by aggregating the reaction times of each condition/ participant and subjecting these data to a ?repeated measurements ANOVA. An example call would be aov(x ~ expCond + Error(pbn/(expCond)), data = data.file.agg) How would an equivalent call for mixed models look like? And how a call which uses the raw data (each 100 measures and not the mean thereof)? Please see an example of such a dataset and the procedure of analysis below. Sincerly, Henning B. ## Create Datafile n.pbn = 100 n.expCond = 3 n.trial = 100 # 100 trials per condition data.file <- matrix(NA, ncol = 3, nrow = n.pbn * n.expCond * n.trial) data.file <- as.data.frame(data.file) names(data.file) <- c("pbn", "expCond", "rt") data.file$pbn <- rep(1:n.pbn, each = n.expCond * n.trial) data.file$expCond <- rep(rep(1:n.expCond, each = n.trial), n.pbn) for (i in 1:n.pbn){ mean.rt <- rnorm(1, mean = 300, sd = 50) rt.expCond1 <- rnorm(n.trial, mean = mean.rt, sd = 100) rt.expCond2 <- rnorm(n.trial, mean = mean.rt + 20, sd = 100) rt.expCond3 <- rnorm(n.trial, mean = mean.rt + 40, sd = 100) data.file[data.file$pbn == i & data.file$expCond == 1,]$rt <- rt.expCond1 data.file[data.file$pbn == i & data.file$expCond == 2,]$rt <- rt.expCond2 data.file[data.file$pbn == i & data.file$expCond == 3,]$rt <- rt.expCond3 } ## Aggregate Datafile data.file.agg <- evalq(aggregate(rt, list(pbn = pbn, expCond = expCond), mean), data.file) data.file.agg$expCond <- factor(data.file.agg$expCond) ## Compute p-value of ANOVA rt.aov <- aov(x ~ expCond + Error(pbn/(expCond)), data = data.file.agg) summary(rt.aov)[[3]][[1]][1,"Pr(>F)"] -- View this message in context: http://r.789695.n4.nabble.com/Mixed-Model-analysis-instead-of-repeated-measures-ANOVA-how-to-call-lmer-or-lme-instead-of-aov-tp3080388p3080388.html Sent from the R help mailing list archive at Nabble.com.