Inconsistent EMMEANS results in R and Rj Editor
Posted: Tue Mar 12, 2019 7:27 pm
Hi,
The emmeans for a mixed ANOVA model in the Rj Editor produces different results from those run in R. Here are the codes.
Here is the result produced in RStudio
The result produced by Rj Editor is attached. The anova models agree but the emmeans estimates were all off.
Best,
Kris
The emmeans for a mixed ANOVA model in the Rj Editor produces different results from those run in R. Here are the codes.
Code: Select all
id <- factor(c(1:30,1:30))
cond <- c("A","A","A","A","A","A","A","A","A","A",
"B","B","B","B","B","B","B","B","B","B",
"C","C","C","C","C","C","C","C","C","C",
"A","A","A","A","A","A","A","A","A","A",
"B","B","B","B","B","B","B","B","B","B",
"C","C","C","C","C","C","C","C","C","C")
time <- c(rep("baseline",30), rep("train",30))
y <- c( 8,5,3,5,2,6,5,6,4,4,
3,5,8,2,5,6,6,4,3,5,
3,5,8,5,5,6,6,6,3,4,
9,7,2,7,9,7,8,5,7,9,
5,5,10,5,3,10,9,5,7,5,
4,5,6,6,4,7,7,3,2,2)
a <- data.frame(id,cond,time,y)
# Fit Mixed ANOVA
fit <- aov(y ~ cond * time + Error(id/time), data = a)
summary(fit)
# EMMEANS
library("emmeans")
fit.emm <- emmeans(fit, ~ cond | time)
summary(fit.emm)
Code: Select all
##Error: id
## Df Sum Sq Mean Sq F value Pr(>F)
##cond 2 11.43 5.717 1.041 0.367
##Residuals 27 148.30 5.493
##
##Error: id:time
## Df Sum Sq Mean Sq F value Pr(>F)
##time 1 19.27 19.267 9.441 0.00481 **
##cond:time 2 20.63 10.317 5.055 0.01365 *
##Residuals 27 55.10 2.041
##---
##Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
##
##time = baseline:
## cond emmean SE df lower.CL upper.CL
## A 4.8 0.6137318 44.63 3.563598 6.036402
## B 4.7 0.6137318 44.63 3.463598 5.936402
## C 5.1 0.6137318 44.63 3.863598 6.336402
##
##time = train:
## cond emmean SE df lower.CL upper.CL
## A 7.0 0.6137318 44.63 5.763598 8.236402
## B 6.4 0.6137318 44.63 5.163598 7.636402
## C 4.6 0.6137318 44.63 3.363598 5.836402
##
##Confidence level used: 0.95
Best,
Kris