$Time1
Shapiro-Wilk normality test
data: x
W = 0.91913, p-value = 0.2788
$Time2
Shapiro-Wilk normality test
data: x
W = 0.88011, p-value = 0.08792
$Time3
Shapiro-Wilk normality test
data: x
W = 0.73897, p-value = 0.002055
$id
Shapiro-Wilk normality test
data: x
W = 0.95933, p-value = 0.7742
批量运行方差齐性查验(Levene's Test)
for(i in unique(data2$x)){ data1 <- data2[data2$x == i,] print(leveneTest(value~trt, data = data1))}
Levene's Test for Homogeneity of Variance (center = median)
Df F value Pr(>F)
group 1 1.5617 0.2245
22
Levene's Test for Homogeneity of Variance (center = median)
Df F value Pr(>F)
group 1 2.5864 0.122
22
Levene's Test for Homogeneity of Variance (center = median)
Df F value Pr(>F)
group 1 3.8375 0.06291 .
22
Signif. codes: 0 ‘’ 0.001 ‘’ 0.01 ‘’ 0.05 ‘.’ 0.1 ‘ ’ 1
两因素重复测量方差分析
anova_test(data = data2, dv = value, wid = id, within = x, between = trt)
ANOVA Table (type II tests)
$ANOVA
Effect DFn DFd F p p<.05 ges
1 trt 1 22 510.657 1.02e-16 * 0.918
2 x 2 44 391.826 9.19e-29 * 0.902
3 trt:x 2 44 407.706 4.01e-29 * 0.905
$Mauchly's Test for Sphericity
Effect W p p<.05
1 x 0.966 0.699
2 trt:x 0.966 0.699
$Sphericity Corrections
Effect GGe DF[GG] p[GG] p[GG]<.05 HFe DF[HF] p[HF] p[HF]<.05
1 x 0.968 1.94, 42.57 6.65e-28 * 1.059 2.12, 46.61 9.19e-29 *
2 trt:x 0.968 1.94, 42.57 2.98e-28 * 1.059 2.12, 46.61 4.01e-29 *
可视化结果
ggplot(data = data3, aes(x = x, y = mean, color = trt, group = trt)) + geom_errorbar(aes(ymin=mean-sd, ymax=mean+sd), color = "black", width = 0.2) + geom_line() + geom_point() + theme_bw()