[R-sig-ME] Paired ttest using lme4
Ghader Mirzaghaderi
gh@m|rz@gh@der| @end|ng |rom uok@@c@|r
Mon Jun 17 16:01:25 CEST 2024
Dear Ben,
I appreciate your letting me know how the paired t-test is done using lmer function.
using the following code, the p-value from lmer is different from the paired t.test.
Many thanks
Best regards,
Ghader
tt <- read.table(text = "
g y
1 2.39
1 2.59
1 2.44
2 4.34
2 2.89
2 3.77
", header = T)
t.test(tt$y ~ tt$g, var.equal = F, paired = T)
tt2 <- read.table(text = "
id g y
a1 a 2.39
a2 a 2.59
a3 a 2.44
a1 b 4.34
a2 b 2.89
a3 b 3.77
", header = T)
library(lme4)
library(emmeans)
anova(lmerTest::lmer(y ~ g + (1 | id), data = tt2))
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list