Jeg har et spørgsmål angående output fra {bil} Anova. Jeg vil køre en simpel 2×2 gentagne målinger ANOVA ved hjælp af den multivariate tilgang. Jeg kan køre (ændret) eksemplet fra Anova {car} hjælpesiden:
phase <- factor(rep(c("pretest", "posttest", "followup"), c(5, 5, 5)), levels=c("pretest", "posttest", "followup")) hour <- ordered(rep(1:5, 3)) idata <- data.frame(phase, hour) idata mod.ok <- lm(cbind(pre.1, pre.2, pre.3, pre.4, pre.5, post.1, post.2, post.3, post.4, post.5, fup.1, fup.2, fup.3, fup.4, fup.5) ~ 1, data=OBrienKaiser) (av.ok <- Anova(mod.ok, idata=idata, idesign=~phase*hour) ) b<-summary(av.ok)
Hvilket giver følgende (forkortede) output
Univariate Type III Repeated-Measures ANOVA Assuming Sphericity SS num Df Error SS den Df F Pr(>F) (Intercept) 7260.0 1 603.33 15 180.4972 9.100e-10 *** phase 167.5 2 169.17 30 14.8522 3.286e-05 *** hour 106.3 4 73.71 60 21.6309 4.360e-11 *** phase:hour 11.1 8 122.92 120 1.3525 0.2245 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Mauchly Tests for Sphericity Test statistic p-value phase 0.70470 0.086304 hour 0.11516 0.000718 phase:hour 0.01139 0.027376 Greenhouse-Geisser and Huynh-Feldt Corrections for Departure from Sphericity GG eps Pr(>F[GG]) phase 0.77202 0.0001891 *** hour 0.49842 1.578e-06 *** phase:hour 0.51297 0.2602357 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 HF eps Pr(>F[HF]) phase 0.84367 0.0001089 *** hour 0.57470 3.161e-07 *** phase:hour 0.73031 0.2439922 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Men med mine data (se nedenfor) mangler Greenhouse-Geisser-output:
h2 <- structure(list(A1neg = c(-8.427556992, 1.20452559, -14.331842422, -10.428559303, 1.750265002, 9.388166428, 0.790130436, -1.592002392, 0.539065838, -3.758603573, 8.391399384), B1neg = c(-12.188085556, -1.964554906, -12.247328758, -7.326891422, -0.961694896, -1.048453212, -4.225459576, 0.173920691, 1.876976371, -9.11947155, -1.706287026 ), A1pos = c(-0.660317183, 3.498036146, 22.003242493, 19.905063629, -3.124288321, 11.968006134, 5.838645935, 5.140467644, 5.154311657, 2.298083067, 1.164232969), B1pos = c(-12.805168152, -1.550003886, 45.990013123, 15.915545464, -1.67797184, 7.565258026, 10.635170937, 12.769438744, 11.738276482, 4.544145107, 0.230011433)), .Names = c("A1neg", "B1neg", "A1pos", "B1pos"), class = "data.frame", row.names = c("1", "11", "21", "31", "41", "51", "61", "71", "81", "91", "101")) condition <- ordered(rep(c("A", "B"), c(2)), levels=c("A", "B")) reg <- factor(rep(c("neg", "pos"), c(2,2)), levels=c("neg", "pos")) idata<-data.frame(condition, reg) idata mod.ok<-lm(cbind( A1neg,B1neg,A1pos,B1pos) ~ 1, data=h2) (av.ok<-Anova(mod.ok, idata=idata, idesign=~condition*reg)) summary(av.ok)
Dette giver:
Univariate Type III Repeated-Measures ANOVA Assuming Sphericity SS num Df Error SS den Df F Pr(>F) (Intercept) 233.35 1 995.14 10 2.3449 0.15669 condition 3.32 1 373.00 10 0.0891 0.77143 reg 1220.66 1 2135.77 10 5.7153 0.03791 * condition:reg 62.48 1 176.90 10 3.5318 0.08963 . --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 >
Har du nogen ideer, hvad gik der galt?
Svar
Intet gik galt. Programmet gjorde præcis, hvad det var meningen at gøre. Det skyldes, at du kun har et 2×2 faktorielt design i dit eksempel. Mauchlys test for sfæricitet sammenligner forskelle mellem forskelle mellem niveauer af gentagne målefaktorer. En anden måde at se på det er kovariansmatrixen i design af gentagne målinger. Hvis du har et 2×2 design, er der kun en kovarians, se på følgende varians-kovariansmatrix (hvor $ A1 $ og $ A2 $ er de gentagne målinger):
$$ \ left (\ begin {array} {ccc} Var (A1) & Cov (A1, A2) \\ Cov (A2, A1) & Var (A2) \ end {array} \ right) $$
Der er kun en kovarians (kovarians er symmetrisk), nemlig $ Cov (A1, A2) = Cov (A2, A1) $. Derfor er der kun en varians af forskellen $ Var (A1-A2) $. Så: i et 2×2 design, antages sfærisk antagelse altid . Det er derfor, at funktionen summary.Anova.mlm
ikke beregner Mauchlys test, og der gives ingen drivhus-Geisser-korrektioner i output. Her er en meget god forklaring på sfæricitet, og dit problem nævnes også (sektion “Komplikationer”).
Se hvad der sker, hvis vi tilføjer et andet niveau til dit eksempel (jeg lavede dataene til “C”):
h2 <- structure(list(A1neg = c(-8.427556992, 1.20452559, -14.331842422, -10.428559303, 1.750265002, 9.388166428, 0.790130436, -1.592002392, 0.539065838, -3.758603573, 8.391399384), B1neg = c(-12.188085556, -1.964554906, -12.247328758, -7.326891422, -0.961694896, -1.048453212, -4.225459576, 0.173920691, 1.876976371, -9.11947155, -1.706287026), C1neg = c(1.750265002, 0.539065838, 1.20452559, 8.391399384, -3.758603573, -7.326891422, 0.790130436, -9.11947155, -1.592002392, -12.188085556, -10.428559303), A1pos = c(-0.660317183, 3.498036146, 22.003242493, 19.905063629, -3.124288321, 11.968006134, 5.838645935, 5.140467644, 5.154311657, 2.298083067, 1.164232969), B1pos = c(-12.805168152, -1.550003886, 45.990013123, 15.915545464, -1.67797184, 7.565258026, 10.635170937, 12.769438744, 11.738276482, 4.544145107, 0.230011433), C1pos= c(-1.550003886, 1.164232969, 11.738276482, 5.838645935, -12.805168152, -0.660317183, 22.003242493, 19.905063629, 0.230011433, 7.565258026, 5.154311657)), .Names = c("A1neg", "B1neg", "C1neg", "A1pos", "B1pos", "C1pos"), class = "data.frame", row.names = c("1", "11", "21", "31", "41", "51", "61", "71", "81", "91", "101")) condition <- ordered(rep(c("A", "B", "C"), c(2)), levels=c("A", "B", "C")) reg <- factor(rep(c("neg", "pos"), c(3,3)), levels=c("neg", "pos")) idata<-data.frame(condition, reg) idata mod.ok<-lm(cbind(A1neg,B1neg,C1neg, A1pos,B1pos,C1pos) ~ 1, data=h2) (av.ok<-Anova(mod.ok, idata=idata, idesign=~condition*reg)) summary(av.ok)
Nu viser output Mauchlys test og Greenhouse-Geisser-korrektionen.
Univariate Type III Repeated-Measures ANOVA Assuming Sphericity SS num Df Error SS den Df F Pr(>F) (Intercept) 248.91 1 1158.47 10 2.1486 0.17342 condition 20.52 2 875.91 20 0.2342 0.79333 reg 1571.69 1 1789.74 10 8.7817 0.01421 * condition:reg 82.27 2 1244.02 20 0.6613 0.52710 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Mauchly Tests for Sphericity Test statistic p-value condition 0.97043 0.87365 condition:reg 0.48792 0.03959 Greenhouse-Geisser and Huynh-Feldt Corrections for Departure from Sphericity GG eps Pr(>F[GG]) condition 0.97128 0.7872 condition:reg 0.66134 0.4719 HF eps Pr(>F[HF]) condition 1.20188 0.7933 condition:reg 0.72312 0.4838
Kommentarer
- Perfekt, mange tak for forklaringen og for at give linket.
- @RubenReal You ‘ er velkommen. Glad for, at jeg kunne hjælpe.