Johan Steen
2010-Aug-23 19:01 UTC
[R] extracting p-values from Anova objects (from the car library)
Dear all, is there anyone who can help me extracting p-values from an Anova object from the car library? I can't seem to locate the p-values using str(result) or str(summary(result)) in the example below > A <- factor( rep(1:2,each=3) ) > B <- factor( rep(1:3,times=2) ) > idata <- data.frame(A,B) > fit <- lm( cbind(a1_b1,a1_b2,a1_b3,a2_b1,a2_b2,a2_b3) ? sex, data=Data.wide) > result <- Anova(fit, type="III", test="Wilks", idata=idata, idesign=?A*B) Any help would be much appreciated! Many thanks, Johan
David Winsemius
2010-Aug-23 19:56 UTC
[R] extracting p-values from Anova objects (from the car library)
On Aug 23, 2010, at 3:01 PM, Johan Steen wrote:> Dear all, > > is there anyone who can help me extracting p-values from an Anova > object from the car library? I can't seem to locate the p-values > using str(result) or str(summary(result)) in the example below > > > A <- factor( rep(1:2,each=3) ) > > B <- factor( rep(1:3,times=2) ) > > idata <- data.frame(A,B) > > fit <- lm( cbind(a1_b1,a1_b2,a1_b3,a2_b1,a2_b2,a2_b3) ? sex, > data=Data.wide) > > result <- Anova(fit, type="III", test="Wilks", idata=idata, > idesign=?A*B)# you forgot require(car) > A <- factor( rep(1:2,each=3) ) > B <- factor( rep(1:3,times=2) ) > idata <- data.frame(A,B) > fit <- lm( cbind(a1_b1,a1_b2,a1_b3,a2_b1,a2_b2,a2_b3)~sex, data=Data.wide) Error in inherits(x, "data.frame") : object 'Data.wide' not found I am guessing that you have an object Data.wide and you are not giving us any look at it. Using the lm help page example: It appears that the print method for Anova is what would return the p- values: prtAnova <- Anova(lm.D9 <- lm(weight ~ group), type="III") > str(prtAnova ) Classes ?anova? and 'data.frame': 3 obs. of 4 variables: $ Sum Sq : num 253.21 0.688 8.729 $ Df : num 1 1 18 $ F value: num 522.13 1.42 NA $ Pr(>F) : num 9.55e-15 2.49e-01 NA - attr(*, "heading")= chr "Anova Table (Type III tests)\n" "Response: weight" So htis is one way: > prtAnova$'Pr(>F)' [1] 9.547128e-15 2.490232e-01 NA Further examination makes me wonder why you decided that the summary method did not produce a p-value? > sumryAnova <- summary(Anova(lm.D9 <- lm(weight ~ group), type="III")) > str(sumryAnova) 'table' chr [1:7, 1:4] "Min. : 0.6882 " "1st Qu.: 4.7087 " "Median : 8.7293 " ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:7] "" "" "" "" ... ..$ : chr [1:4] " Sum Sq" " Df" " F value" " Pr(>F)" Perhaps perhaps you didn't realize that Pr(>F) was the p-value? (It would be a bit more difficult to get the p-value from the summary object since it needs to be extracted with attribute functions. -- David Winsemius, MD West Hartford, CT
Johan Steen
2010-Aug-23 21:35 UTC
[R] extracting p-values from Anova objects (from the car library)
Thanks for your replies, but unfortunately none of them seem to help. I do get p-values in the output, but can't seem to locate them anywhere in these objects via the str() function. I also get very different output using str() than you obtained from the lm help page Here's my output: > A <- factor( rep(1:2,each=3) ) > B <- factor( rep(1:3,times=2) ) > idata <- data.frame(A,B) > idata A B 1 1 1 2 1 2 3 1 3 4 2 1 5 2 2 6 2 3 > > fit <- lm( cbind(a1_b1,a1_b2,a1_b3,a2_b1,a2_b2,a2_b3) ~ sex, data=Data.wide) > result <- Anova(fit, type="III", test="Wilks", idata=idata, idesign=~A*B) > result Type III Repeated Measures MANOVA Tests: Wilks test statistic Df test stat approx F num Df den Df Pr(>F) (Intercept) 1 0.02863 610.81 1 18 2.425e-15 sex 1 0.76040 5.67 1 18 0.02849 A 1 0.91390 1.70 1 18 0.20925 sex:A 1 0.99998 0.00 1 18 0.98536 B 1 0.26946 23.05 2 17 1.443e-05 sex:B 1 0.98394 0.14 2 17 0.87140 A:B 1 0.27478 22.43 2 17 1.704e-05 sex:A:B 1 0.98428 0.14 2 17 0.87397 > summary(result) Type III Repeated Measures MANOVA Tests: ------------------------------------------ Term: (Intercept) Response transformation matrix: (Intercept) a1_b1 1 a1_b2 1 a1_b3 1 a2_b1 1 a2_b2 1 a2_b3 1 Sum of squares and products for the hypothesis: (Intercept) (Intercept) 1169345 Sum of squares and products for error: (Intercept) (Intercept) 34459.4 Multivariate Tests: (Intercept) Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.97137 610.8117 1 18 2.425e-15 Wilks 1 0.02863 610.8117 1 18 2.425e-15 Hotelling-Lawley 1 33.93399 610.8117 1 18 2.425e-15 Roy 1 33.93399 610.8117 1 18 2.425e-15 ------------------------------------------ Term: sex Response transformation matrix: (Intercept) a1_b1 1 a1_b2 1 a1_b3 1 a2_b1 1 a2_b2 1 a2_b3 1 Sum of squares and products for the hypothesis: (Intercept) (Intercept) 10857.8 Sum of squares and products for error: (Intercept) (Intercept) 34459.4 Multivariate Tests: sex Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.2395956 5.671614 1 18 0.028486 Wilks 1 0.7604044 5.671614 1 18 0.028486 Hotelling-Lawley 1 0.3150896 5.671614 1 18 0.028486 Roy 1 0.3150896 5.671614 1 18 0.028486 ------------------------------------------ Term: A Response transformation matrix: A1 a1_b1 1 a1_b2 1 a1_b3 1 a2_b1 -1 a2_b2 -1 a2_b3 -1 Sum of squares and products for the hypothesis: A1 A1 980 Sum of squares and products for error: A1 A1 10401.8 Multivariate Tests: A Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.0861024 1.695860 1 18 0.20925 Wilks 1 0.9138976 1.695860 1 18 0.20925 Hotelling-Lawley 1 0.0942145 1.695860 1 18 0.20925 Roy 1 0.0942145 1.695860 1 18 0.20925 ------------------------------------------ Term: sex:A Response transformation matrix: A1 a1_b1 1 a1_b2 1 a1_b3 1 a2_b1 -1 a2_b2 -1 a2_b3 -1 Sum of squares and products for the hypothesis: A1 A1 0.2 Sum of squares and products for error: A1 A1 10401.8 Multivariate Tests: sex:A Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.0000192 0.0003460939 1 18 0.98536 Wilks 1 0.9999808 0.0003460939 1 18 0.98536 Hotelling-Lawley 1 0.0000192 0.0003460939 1 18 0.98536 Roy 1 0.0000192 0.0003460939 1 18 0.98536 ------------------------------------------ Term: B Response transformation matrix: B1 B2 a1_b1 1 0 a1_b2 0 1 a1_b3 -1 -1 a2_b1 1 0 a2_b2 0 1 a2_b3 -1 -1 Sum of squares and products for the hypothesis: B1 B2 B1 3618.05 3443.2 B2 3443.20 3276.8 Sum of squares and products for error: B1 B2 B1 2304.5 1396.8 B2 1396.8 1225.2 Multivariate Tests: B Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.730544 23.04504 2 17 1.4426e-05 Wilks 1 0.269456 23.04504 2 17 1.4426e-05 Hotelling-Lawley 1 2.711181 23.04504 2 17 1.4426e-05 Roy 1 2.711181 23.04504 2 17 1.4426e-05 ------------------------------------------ Term: sex:B Response transformation matrix: B1 B2 a1_b1 1 0 a1_b2 0 1 a1_b3 -1 -1 a2_b1 1 0 a2_b2 0 1 a2_b3 -1 -1 Sum of squares and products for the hypothesis: B1 B2 B1 26.45 23 B2 23.00 20 Sum of squares and products for error: B1 B2 B1 2304.5 1396.8 B2 1396.8 1225.2 Multivariate Tests: sex:B Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.0160644 0.1387764 2 17 0.8714 Wilks 1 0.9839356 0.1387764 2 17 0.8714 Hotelling-Lawley 1 0.0163266 0.1387764 2 17 0.8714 Roy 1 0.0163266 0.1387764 2 17 0.8714 ------------------------------------------ Term: A:B Response transformation matrix: A1:B1 A1:B2 a1_b1 1 0 a1_b2 0 1 a1_b3 -1 -1 a2_b1 -1 0 a2_b2 0 -1 a2_b3 1 1 Sum of squares and products for the hypothesis: A1:B1 A1:B2 A1:B1 5152.05 738.3 A1:B2 738.30 105.8 Sum of squares and products for error: A1:B1 A1:B2 A1:B1 3210.5 1334.4 A1:B2 1334.4 924.0 Multivariate Tests: A:B Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.7252156 22.43334 2 17 1.7039e-05 Wilks 1 0.2747844 22.43334 2 17 1.7039e-05 Hotelling-Lawley 1 2.6392162 22.43334 2 17 1.7039e-05 Roy 1 2.6392162 22.43334 2 17 1.7039e-05 ------------------------------------------ Term: sex:A:B Response transformation matrix: A1:B1 A1:B2 a1_b1 1 0 a1_b2 0 1 a1_b3 -1 -1 a2_b1 -1 0 a2_b2 0 -1 a2_b3 1 1 Sum of squares and products for the hypothesis: A1:B1 A1:B2 A1:B1 26.45 2.3 A1:B2 2.30 0.2 Sum of squares and products for error: A1:B1 A1:B2 A1:B1 3210.5 1334.4 A1:B2 1334.4 924.0 Multivariate Tests: sex:A:B Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.0157232 0.1357821 2 17 0.87397 Wilks 1 0.9842768 0.1357821 2 17 0.87397 Hotelling-Lawley 1 0.0159744 0.1357821 2 17 0.87397 Roy 1 0.0159744 0.1357821 2 17 0.87397 Univariate Type III Repeated-Measures ANOVA Assuming Sphericity SS num Df Error SS den Df F Pr(>F) (Intercept) 194891 1 5743.2 18 610.8117 2.425e-15 sex 1810 1 5743.2 18 5.6716 0.02849 A 163 1 1733.6 18 1.6959 0.20925 sex:A 0 1 1733.6 18 0.0003 0.98536 B 1151 2 711.0 36 29.1292 2.990e-08 sex:B 8 2 711.0 36 0.1979 0.82134 A:B 1507 2 933.4 36 29.0532 3.078e-08 sex:A:B 8 2 933.4 36 0.1565 0.85568 Mauchly Tests for Sphericity Test statistic p-value B 0.57532 0.0091036 sex:B 0.57532 0.0091036 A:B 0.45375 0.0012104 sex:A:B 0.45375 0.0012104 Greenhouse-Geisser and Huynh-Feldt Corrections for Departure from Sphericity GG eps Pr(>F[GG]) B 0.70191 2.143e-06 sex:B 0.70191 0.7427 A:B 0.64672 4.838e-06 sex:A:B 0.64672 0.7599 HF eps Pr(>F[HF]) B 0.74332 1.181e-06 sex:B 0.74332 0.7560 A:B 0.67565 3.191e-06 sex:A:B 0.67565 0.7702 > str(result) List of 13 $ SSP :List of 8 ..$ (Intercept): num [1, 1] 1169345 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr "(Intercept)" .. .. ..$ : chr "(Intercept)" ..$ sex : num [1, 1] 10858 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr "(Intercept)" .. .. ..$ : chr "(Intercept)" ..$ A : num [1, 1] 980 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr "A1" .. .. ..$ : chr "A1" ..$ sex:A : num [1, 1] 0.2 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr "A1" .. .. ..$ : chr "A1" ..$ B : num [1:2, 1:2] 3618 3443 3443 3277 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:2] "B1" "B2" .. .. ..$ : chr [1:2] "B1" "B2" ..$ sex:B : num [1:2, 1:2] 26.4 23 23 20 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:2] "B1" "B2" .. .. ..$ : chr [1:2] "B1" "B2" ..$ A:B : num [1:2, 1:2] 5152 738 738 106 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" ..$ sex:A:B : num [1:2, 1:2] 26.4 2.3 2.3 0.2 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" $ SSPE :List of 8 ..$ (Intercept): num [1, 1] 34459 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr "(Intercept)" .. .. ..$ : chr "(Intercept)" ..$ sex : num [1, 1] 34459 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr "(Intercept)" .. .. ..$ : chr "(Intercept)" ..$ A : num [1, 1] 10402 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr "A1" .. .. ..$ : chr "A1" ..$ sex:A : num [1, 1] 10402 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr "A1" .. .. ..$ : chr "A1" ..$ B : num [1:2, 1:2] 2304 1397 1397 1225 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:2] "B1" "B2" .. .. ..$ : chr [1:2] "B1" "B2" ..$ sex:B : num [1:2, 1:2] 2304 1397 1397 1225 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:2] "B1" "B2" .. .. ..$ : chr [1:2] "B1" "B2" ..$ A:B : num [1:2, 1:2] 3210 1334 1334 924 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" ..$ sex:A:B : num [1:2, 1:2] 3210 1334 1334 924 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" $ P :List of 8 ..$ (Intercept): num [1:6, 1] 1 1 1 1 1 1 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... .. .. ..$ : chr "(Intercept)" ..$ sex : num [1:6, 1] 1 1 1 1 1 1 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... .. .. ..$ : chr "(Intercept)" ..$ A : num [1:6, 1] 1 1 1 -1 -1 -1 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... .. .. ..$ : chr "A1" ..$ sex:A : num [1:6, 1] 1 1 1 -1 -1 -1 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... .. .. ..$ : chr "A1" ..$ B : num [1:6, 1:2] 1 0 -1 1 0 -1 0 1 -1 0 ... .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... .. .. ..$ : chr [1:2] "B1" "B2" ..$ sex:B : num [1:6, 1:2] 1 0 -1 1 0 -1 0 1 -1 0 ... .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... .. .. ..$ : chr [1:2] "B1" "B2" ..$ A:B : num [1:6, 1:2] 1 0 -1 -1 0 1 0 1 -1 0 ... .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" ..$ sex:A:B : num [1:6, 1:2] 1 0 -1 -1 0 1 0 1 -1 0 ... .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" $ df : Named num [1:8] 1 1 1 1 1 1 1 1 ..- attr(*, "names")= chr [1:8] "(Intercept)" "sex" "A" "sex:A" ... $ error.df : int 18 $ terms : chr [1:8] "(Intercept)" "sex" "A" "sex:A" ... $ repeated : logi TRUE $ type : chr "III" $ test : chr "Wilks" $ idata :'data.frame': 6 obs. of 2 variables: ..$ A: Factor w/ 2 levels "1","2": 1 1 1 2 2 2 .. ..- attr(*, "contrasts")= chr "contr.sum" ..$ B: Factor w/ 3 levels "1","2","3": 1 2 3 1 2 3 .. ..- attr(*, "contrasts")= chr "contr.sum" $ idesign :Class 'formula' length 2 ~A * B .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> $ icontrasts: chr [1:2] "contr.sum" "contr.poly" $ imatrix : NULL - attr(*, "class")= chr "Anova.mlm" > str(summary(result)) Type III Repeated Measures MANOVA Tests: ------------------------------------------ Term: (Intercept) Response transformation matrix: (Intercept) a1_b1 1 a1_b2 1 a1_b3 1 a2_b1 1 a2_b2 1 a2_b3 1 Sum of squares and products for the hypothesis: (Intercept) (Intercept) 1169345 Sum of squares and products for error: (Intercept) (Intercept) 34459.4 Multivariate Tests: (Intercept) Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.97137 610.8117 1 18 2.425e-15 Wilks 1 0.02863 610.8117 1 18 2.425e-15 Hotelling-Lawley 1 33.93399 610.8117 1 18 2.425e-15 Roy 1 33.93399 610.8117 1 18 2.425e-15 ------------------------------------------ Term: sex Response transformation matrix: (Intercept) a1_b1 1 a1_b2 1 a1_b3 1 a2_b1 1 a2_b2 1 a2_b3 1 Sum of squares and products for the hypothesis: (Intercept) (Intercept) 10857.8 Sum of squares and products for error: (Intercept) (Intercept) 34459.4 Multivariate Tests: sex Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.2395956 5.671614 1 18 0.028486 Wilks 1 0.7604044 5.671614 1 18 0.028486 Hotelling-Lawley 1 0.3150896 5.671614 1 18 0.028486 Roy 1 0.3150896 5.671614 1 18 0.028486 ------------------------------------------ Term: A Response transformation matrix: A1 a1_b1 1 a1_b2 1 a1_b3 1 a2_b1 -1 a2_b2 -1 a2_b3 -1 Sum of squares and products for the hypothesis: A1 A1 980 Sum of squares and products for error: A1 A1 10401.8 Multivariate Tests: A Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.0861024 1.695860 1 18 0.20925 Wilks 1 0.9138976 1.695860 1 18 0.20925 Hotelling-Lawley 1 0.0942145 1.695860 1 18 0.20925 Roy 1 0.0942145 1.695860 1 18 0.20925 ------------------------------------------ Term: sex:A Response transformation matrix: A1 a1_b1 1 a1_b2 1 a1_b3 1 a2_b1 -1 a2_b2 -1 a2_b3 -1 Sum of squares and products for the hypothesis: A1 A1 0.2 Sum of squares and products for error: A1 A1 10401.8 Multivariate Tests: sex:A Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.0000192 0.0003460939 1 18 0.98536 Wilks 1 0.9999808 0.0003460939 1 18 0.98536 Hotelling-Lawley 1 0.0000192 0.0003460939 1 18 0.98536 Roy 1 0.0000192 0.0003460939 1 18 0.98536 ------------------------------------------ Term: B Response transformation matrix: B1 B2 a1_b1 1 0 a1_b2 0 1 a1_b3 -1 -1 a2_b1 1 0 a2_b2 0 1 a2_b3 -1 -1 Sum of squares and products for the hypothesis: B1 B2 B1 3618.05 3443.2 B2 3443.20 3276.8 Sum of squares and products for error: B1 B2 B1 2304.5 1396.8 B2 1396.8 1225.2 Multivariate Tests: B Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.730544 23.04504 2 17 1.4426e-05 Wilks 1 0.269456 23.04504 2 17 1.4426e-05 Hotelling-Lawley 1 2.711181 23.04504 2 17 1.4426e-05 Roy 1 2.711181 23.04504 2 17 1.4426e-05 ------------------------------------------ Term: sex:B Response transformation matrix: B1 B2 a1_b1 1 0 a1_b2 0 1 a1_b3 -1 -1 a2_b1 1 0 a2_b2 0 1 a2_b3 -1 -1 Sum of squares and products for the hypothesis: B1 B2 B1 26.45 23 B2 23.00 20 Sum of squares and products for error: B1 B2 B1 2304.5 1396.8 B2 1396.8 1225.2 Multivariate Tests: sex:B Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.0160644 0.1387764 2 17 0.8714 Wilks 1 0.9839356 0.1387764 2 17 0.8714 Hotelling-Lawley 1 0.0163266 0.1387764 2 17 0.8714 Roy 1 0.0163266 0.1387764 2 17 0.8714 ------------------------------------------ Term: A:B Response transformation matrix: A1:B1 A1:B2 a1_b1 1 0 a1_b2 0 1 a1_b3 -1 -1 a2_b1 -1 0 a2_b2 0 -1 a2_b3 1 1 Sum of squares and products for the hypothesis: A1:B1 A1:B2 A1:B1 5152.05 738.3 A1:B2 738.30 105.8 Sum of squares and products for error: A1:B1 A1:B2 A1:B1 3210.5 1334.4 A1:B2 1334.4 924.0 Multivariate Tests: A:B Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.7252156 22.43334 2 17 1.7039e-05 Wilks 1 0.2747844 22.43334 2 17 1.7039e-05 Hotelling-Lawley 1 2.6392162 22.43334 2 17 1.7039e-05 Roy 1 2.6392162 22.43334 2 17 1.7039e-05 ------------------------------------------ Term: sex:A:B Response transformation matrix: A1:B1 A1:B2 a1_b1 1 0 a1_b2 0 1 a1_b3 -1 -1 a2_b1 -1 0 a2_b2 0 -1 a2_b3 1 1 Sum of squares and products for the hypothesis: A1:B1 A1:B2 A1:B1 26.45 2.3 A1:B2 2.30 0.2 Sum of squares and products for error: A1:B1 A1:B2 A1:B1 3210.5 1334.4 A1:B2 1334.4 924.0 Multivariate Tests: sex:A:B Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.0157232 0.1357821 2 17 0.87397 Wilks 1 0.9842768 0.1357821 2 17 0.87397 Hotelling-Lawley 1 0.0159744 0.1357821 2 17 0.87397 Roy 1 0.0159744 0.1357821 2 17 0.87397 Univariate Type III Repeated-Measures ANOVA Assuming Sphericity SS num Df Error SS den Df F Pr(>F) (Intercept) 194891 1 5743.2 18 610.8117 2.425e-15 sex 1810 1 5743.2 18 5.6716 0.02849 A 163 1 1733.6 18 1.6959 0.20925 sex:A 0 1 1733.6 18 0.0003 0.98536 B 1151 2 711.0 36 29.1292 2.990e-08 sex:B 8 2 711.0 36 0.1979 0.82134 A:B 1507 2 933.4 36 29.0532 3.078e-08 sex:A:B 8 2 933.4 36 0.1565 0.85568 Mauchly Tests for Sphericity Test statistic p-value B 0.57532 0.0091036 sex:B 0.57532 0.0091036 A:B 0.45375 0.0012104 sex:A:B 0.45375 0.0012104 Greenhouse-Geisser and Huynh-Feldt Corrections for Departure from Sphericity GG eps Pr(>F[GG]) B 0.70191 2.143e-06 sex:B 0.70191 0.7427 A:B 0.64672 4.838e-06 sex:A:B 0.64672 0.7599 HF eps Pr(>F[HF]) B 0.74332 1.181e-06 sex:B 0.74332 0.7560 A:B 0.67565 3.191e-06 sex:A:B 0.67565 0.7702 List of 13 $ SSP :List of 8 ..$ (Intercept): num [1, 1] 1169345 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr "(Intercept)" .. .. ..$ : chr "(Intercept)" ..$ sex : num [1, 1] 10858 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr "(Intercept)" .. .. ..$ : chr "(Intercept)" ..$ A : num [1, 1] 980 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr "A1" .. .. ..$ : chr "A1" ..$ sex:A : num [1, 1] 0.2 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr "A1" .. .. ..$ : chr "A1" ..$ B : num [1:2, 1:2] 3618 3443 3443 3277 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:2] "B1" "B2" .. .. ..$ : chr [1:2] "B1" "B2" ..$ sex:B : num [1:2, 1:2] 26.4 23 23 20 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:2] "B1" "B2" .. .. ..$ : chr [1:2] "B1" "B2" ..$ A:B : num [1:2, 1:2] 5152 738 738 106 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" ..$ sex:A:B : num [1:2, 1:2] 26.4 2.3 2.3 0.2 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" $ SSPE :List of 8 ..$ (Intercept): num [1, 1] 34459 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr "(Intercept)" .. .. ..$ : chr "(Intercept)" ..$ sex : num [1, 1] 34459 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr "(Intercept)" .. .. ..$ : chr "(Intercept)" ..$ A : num [1, 1] 10402 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr "A1" .. .. ..$ : chr "A1" ..$ sex:A : num [1, 1] 10402 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr "A1" .. .. ..$ : chr "A1" ..$ B : num [1:2, 1:2] 2304 1397 1397 1225 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:2] "B1" "B2" .. .. ..$ : chr [1:2] "B1" "B2" ..$ sex:B : num [1:2, 1:2] 2304 1397 1397 1225 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:2] "B1" "B2" .. .. ..$ : chr [1:2] "B1" "B2" ..$ A:B : num [1:2, 1:2] 3210 1334 1334 924 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" ..$ sex:A:B : num [1:2, 1:2] 3210 1334 1334 924 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" $ P :List of 8 ..$ (Intercept): num [1:6, 1] 1 1 1 1 1 1 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... .. .. ..$ : chr "(Intercept)" ..$ sex : num [1:6, 1] 1 1 1 1 1 1 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... .. .. ..$ : chr "(Intercept)" ..$ A : num [1:6, 1] 1 1 1 -1 -1 -1 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... .. .. ..$ : chr "A1" ..$ sex:A : num [1:6, 1] 1 1 1 -1 -1 -1 .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... .. .. ..$ : chr "A1" ..$ B : num [1:6, 1:2] 1 0 -1 1 0 -1 0 1 -1 0 ... .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... .. .. ..$ : chr [1:2] "B1" "B2" ..$ sex:B : num [1:6, 1:2] 1 0 -1 1 0 -1 0 1 -1 0 ... .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... .. .. ..$ : chr [1:2] "B1" "B2" ..$ A:B : num [1:6, 1:2] 1 0 -1 -1 0 1 0 1 -1 0 ... .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" ..$ sex:A:B : num [1:6, 1:2] 1 0 -1 -1 0 1 0 1 -1 0 ... .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" $ df : Named num [1:8] 1 1 1 1 1 1 1 1 ..- attr(*, "names")= chr [1:8] "(Intercept)" "sex" "A" "sex:A" ... $ error.df : int 18 $ terms : chr [1:8] "(Intercept)" "sex" "A" "sex:A" ... $ repeated : logi TRUE $ type : chr "III" $ test : chr "Wilks" $ idata :'data.frame': 6 obs. of 2 variables: ..$ A: Factor w/ 2 levels "1","2": 1 1 1 2 2 2 .. ..- attr(*, "contrasts")= chr "contr.sum" ..$ B: Factor w/ 3 levels "1","2","3": 1 2 3 1 2 3 .. ..- attr(*, "contrasts")= chr "contr.sum" $ idesign :Class 'formula' length 2 ~A * B .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> $ icontrasts: chr [1:2] "contr.sum" "contr.poly" $ imatrix : NULL - attr(*, "class")= chr "Anova.mlm" > result$`Pr(>F)` NULL > result[[4]] (Intercept) sex A sex:A B sex:B 1 1 1 1 1 1 A:B sex:A:B 1 1 > Op 23/08/2010 22:23, Johan Steen schreef:> Thanks for your replies, > > but unfortunately none of them seem to help. > I do get p-values in the output, but can't seem to locate them anywhere > in these objects via the str() function. I also get very different > output using str() than you obtained from the lm help page > > Here's my output: > > > A <- factor( rep(1:2,each=3) ) > > B <- factor( rep(1:3,times=2) ) > > idata <- data.frame(A,B) > > idata > A B > 1 1 1 > 2 1 2 > 3 1 3 > 4 2 1 > 5 2 2 > 6 2 3 > > > > fit <- lm( cbind(a1_b1,a1_b2,a1_b3,a2_b1,a2_b2,a2_b3) ~ sex, > data=Data.wide) > > result <- Anova(fit, type="III", test="Wilks", idata=idata, > idesign=~A*B) > > result > > Type III Repeated Measures MANOVA Tests: Wilks test statistic > Df test stat approx F num Df den Df Pr(>F) > (Intercept) 1 0.02863 610.81 1 18 2.425e-15 > sex 1 0.76040 5.67 1 18 0.02849 > A 1 0.91390 1.70 1 18 0.20925 > sex:A 1 0.99998 0.00 1 18 0.98536 > B 1 0.26946 23.05 2 17 1.443e-05 > sex:B 1 0.98394 0.14 2 17 0.87140 > A:B 1 0.27478 22.43 2 17 1.704e-05 > sex:A:B 1 0.98428 0.14 2 17 0.87397 > > summary(result) > > Type III Repeated Measures MANOVA Tests: > > ------------------------------------------ > > Term: (Intercept) > > Response transformation matrix: > (Intercept) > a1_b1 1 > a1_b2 1 > a1_b3 1 > a2_b1 1 > a2_b2 1 > a2_b3 1 > > Sum of squares and products for the hypothesis: > (Intercept) > (Intercept) 1169345 > > Sum of squares and products for error: > (Intercept) > (Intercept) 34459.4 > > Multivariate Tests: (Intercept) > Df test stat approx F num Df den Df Pr(>F) > Pillai 1 0.97137 610.8117 1 18 2.425e-15 > Wilks 1 0.02863 610.8117 1 18 2.425e-15 > Hotelling-Lawley 1 33.93399 610.8117 1 18 2.425e-15 > Roy 1 33.93399 610.8117 1 18 2.425e-15 > > ------------------------------------------ > > Term: sex > > Response transformation matrix: > (Intercept) > a1_b1 1 > a1_b2 1 > a1_b3 1 > a2_b1 1 > a2_b2 1 > a2_b3 1 > > Sum of squares and products for the hypothesis: > (Intercept) > (Intercept) 10857.8 > > Sum of squares and products for error: > (Intercept) > (Intercept) 34459.4 > > Multivariate Tests: sex > Df test stat approx F num Df den Df Pr(>F) > Pillai 1 0.2395956 5.671614 1 18 0.028486 > Wilks 1 0.7604044 5.671614 1 18 0.028486 > Hotelling-Lawley 1 0.3150896 5.671614 1 18 0.028486 > Roy 1 0.3150896 5.671614 1 18 0.028486 > > ------------------------------------------ > > Term: A > > Response transformation matrix: > A1 > a1_b1 1 > a1_b2 1 > a1_b3 1 > a2_b1 -1 > a2_b2 -1 > a2_b3 -1 > > Sum of squares and products for the hypothesis: > A1 > A1 980 > > Sum of squares and products for error: > A1 > A1 10401.8 > > Multivariate Tests: A > Df test stat approx F num Df den Df Pr(>F) > Pillai 1 0.0861024 1.695860 1 18 0.20925 > Wilks 1 0.9138976 1.695860 1 18 0.20925 > Hotelling-Lawley 1 0.0942145 1.695860 1 18 0.20925 > Roy 1 0.0942145 1.695860 1 18 0.20925 > > ------------------------------------------ > > Term: sex:A > > Response transformation matrix: > A1 > a1_b1 1 > a1_b2 1 > a1_b3 1 > a2_b1 -1 > a2_b2 -1 > a2_b3 -1 > > Sum of squares and products for the hypothesis: > A1 > A1 0.2 > > Sum of squares and products for error: > A1 > A1 10401.8 > > Multivariate Tests: sex:A > Df test stat approx F num Df den Df Pr(>F) > Pillai 1 0.0000192 0.0003460939 1 18 0.98536 > Wilks 1 0.9999808 0.0003460939 1 18 0.98536 > Hotelling-Lawley 1 0.0000192 0.0003460939 1 18 0.98536 > Roy 1 0.0000192 0.0003460939 1 18 0.98536 > > ------------------------------------------ > > Term: B > > Response transformation matrix: > B1 B2 > a1_b1 1 0 > a1_b2 0 1 > a1_b3 -1 -1 > a2_b1 1 0 > a2_b2 0 1 > a2_b3 -1 -1 > > Sum of squares and products for the hypothesis: > B1 B2 > B1 3618.05 3443.2 > B2 3443.20 3276.8 > > Sum of squares and products for error: > B1 B2 > B1 2304.5 1396.8 > B2 1396.8 1225.2 > > Multivariate Tests: B > Df test stat approx F num Df den Df Pr(>F) > Pillai 1 0.730544 23.04504 2 17 1.4426e-05 > Wilks 1 0.269456 23.04504 2 17 1.4426e-05 > Hotelling-Lawley 1 2.711181 23.04504 2 17 1.4426e-05 > Roy 1 2.711181 23.04504 2 17 1.4426e-05 > > ------------------------------------------ > > Term: sex:B > > Response transformation matrix: > B1 B2 > a1_b1 1 0 > a1_b2 0 1 > a1_b3 -1 -1 > a2_b1 1 0 > a2_b2 0 1 > a2_b3 -1 -1 > > Sum of squares and products for the hypothesis: > B1 B2 > B1 26.45 23 > B2 23.00 20 > > Sum of squares and products for error: > B1 B2 > B1 2304.5 1396.8 > B2 1396.8 1225.2 > > Multivariate Tests: sex:B > Df test stat approx F num Df den Df Pr(>F) > Pillai 1 0.0160644 0.1387764 2 17 0.8714 > Wilks 1 0.9839356 0.1387764 2 17 0.8714 > Hotelling-Lawley 1 0.0163266 0.1387764 2 17 0.8714 > Roy 1 0.0163266 0.1387764 2 17 0.8714 > > ------------------------------------------ > > Term: A:B > > Response transformation matrix: > A1:B1 A1:B2 > a1_b1 1 0 > a1_b2 0 1 > a1_b3 -1 -1 > a2_b1 -1 0 > a2_b2 0 -1 > a2_b3 1 1 > > Sum of squares and products for the hypothesis: > A1:B1 A1:B2 > A1:B1 5152.05 738.3 > A1:B2 738.30 105.8 > > Sum of squares and products for error: > A1:B1 A1:B2 > A1:B1 3210.5 1334.4 > A1:B2 1334.4 924.0 > > Multivariate Tests: A:B > Df test stat approx F num Df den Df Pr(>F) > Pillai 1 0.7252156 22.43334 2 17 1.7039e-05 > Wilks 1 0.2747844 22.43334 2 17 1.7039e-05 > Hotelling-Lawley 1 2.6392162 22.43334 2 17 1.7039e-05 > Roy 1 2.6392162 22.43334 2 17 1.7039e-05 > > ------------------------------------------ > > Term: sex:A:B > > Response transformation matrix: > A1:B1 A1:B2 > a1_b1 1 0 > a1_b2 0 1 > a1_b3 -1 -1 > a2_b1 -1 0 > a2_b2 0 -1 > a2_b3 1 1 > > Sum of squares and products for the hypothesis: > A1:B1 A1:B2 > A1:B1 26.45 2.3 > A1:B2 2.30 0.2 > > Sum of squares and products for error: > A1:B1 A1:B2 > A1:B1 3210.5 1334.4 > A1:B2 1334.4 924.0 > > Multivariate Tests: sex:A:B > Df test stat approx F num Df den Df Pr(>F) > Pillai 1 0.0157232 0.1357821 2 17 0.87397 > Wilks 1 0.9842768 0.1357821 2 17 0.87397 > Hotelling-Lawley 1 0.0159744 0.1357821 2 17 0.87397 > Roy 1 0.0159744 0.1357821 2 17 0.87397 > > Univariate Type III Repeated-Measures ANOVA Assuming Sphericity > > SS num Df Error SS den Df F Pr(>F) > (Intercept) 194891 1 5743.2 18 610.8117 2.425e-15 > sex 1810 1 5743.2 18 5.6716 0.02849 > A 163 1 1733.6 18 1.6959 0.20925 > sex:A 0 1 1733.6 18 0.0003 0.98536 > B 1151 2 711.0 36 29.1292 2.990e-08 > sex:B 8 2 711.0 36 0.1979 0.82134 > A:B 1507 2 933.4 36 29.0532 3.078e-08 > sex:A:B 8 2 933.4 36 0.1565 0.85568 > > > Mauchly Tests for Sphericity > > Test statistic p-value > B 0.57532 0.0091036 > sex:B 0.57532 0.0091036 > A:B 0.45375 0.0012104 > sex:A:B 0.45375 0.0012104 > > > Greenhouse-Geisser and Huynh-Feldt Corrections > for Departure from Sphericity > > GG eps Pr(>F[GG]) > B 0.70191 2.143e-06 > sex:B 0.70191 0.7427 > A:B 0.64672 4.838e-06 > sex:A:B 0.64672 0.7599 > > HF eps Pr(>F[HF]) > B 0.74332 1.181e-06 > sex:B 0.74332 0.7560 > A:B 0.67565 3.191e-06 > sex:A:B 0.67565 0.7702 > > str(result) > List of 13 > $ SSP :List of 8 > ..$ (Intercept): num [1, 1] 1169345 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr "(Intercept)" > .. .. ..$ : chr "(Intercept)" > ..$ sex : num [1, 1] 10858 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr "(Intercept)" > .. .. ..$ : chr "(Intercept)" > ..$ A : num [1, 1] 980 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr "A1" > .. .. ..$ : chr "A1" > ..$ sex:A : num [1, 1] 0.2 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr "A1" > .. .. ..$ : chr "A1" > ..$ B : num [1:2, 1:2] 3618 3443 3443 3277 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:2] "B1" "B2" > .. .. ..$ : chr [1:2] "B1" "B2" > ..$ sex:B : num [1:2, 1:2] 26.4 23 23 20 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:2] "B1" "B2" > .. .. ..$ : chr [1:2] "B1" "B2" > ..$ A:B : num [1:2, 1:2] 5152 738 738 106 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > ..$ sex:A:B : num [1:2, 1:2] 26.4 2.3 2.3 0.2 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > $ SSPE :List of 8 > ..$ (Intercept): num [1, 1] 34459 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr "(Intercept)" > .. .. ..$ : chr "(Intercept)" > ..$ sex : num [1, 1] 34459 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr "(Intercept)" > .. .. ..$ : chr "(Intercept)" > ..$ A : num [1, 1] 10402 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr "A1" > .. .. ..$ : chr "A1" > ..$ sex:A : num [1, 1] 10402 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr "A1" > .. .. ..$ : chr "A1" > ..$ B : num [1:2, 1:2] 2304 1397 1397 1225 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:2] "B1" "B2" > .. .. ..$ : chr [1:2] "B1" "B2" > ..$ sex:B : num [1:2, 1:2] 2304 1397 1397 1225 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:2] "B1" "B2" > .. .. ..$ : chr [1:2] "B1" "B2" > ..$ A:B : num [1:2, 1:2] 3210 1334 1334 924 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > ..$ sex:A:B : num [1:2, 1:2] 3210 1334 1334 924 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > $ P :List of 8 > ..$ (Intercept): num [1:6, 1] 1 1 1 1 1 1 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... > .. .. ..$ : chr "(Intercept)" > ..$ sex : num [1:6, 1] 1 1 1 1 1 1 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... > .. .. ..$ : chr "(Intercept)" > ..$ A : num [1:6, 1] 1 1 1 -1 -1 -1 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... > .. .. ..$ : chr "A1" > ..$ sex:A : num [1:6, 1] 1 1 1 -1 -1 -1 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... > .. .. ..$ : chr "A1" > ..$ B : num [1:6, 1:2] 1 0 -1 1 0 -1 0 1 -1 0 ... > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... > .. .. ..$ : chr [1:2] "B1" "B2" > ..$ sex:B : num [1:6, 1:2] 1 0 -1 1 0 -1 0 1 -1 0 ... > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... > .. .. ..$ : chr [1:2] "B1" "B2" > ..$ A:B : num [1:6, 1:2] 1 0 -1 -1 0 1 0 1 -1 0 ... > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > ..$ sex:A:B : num [1:6, 1:2] 1 0 -1 -1 0 1 0 1 -1 0 ... > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > $ df : Named num [1:8] 1 1 1 1 1 1 1 1 > ..- attr(*, "names")= chr [1:8] "(Intercept)" "sex" "A" "sex:A" ... > $ error.df : int 18 > $ terms : chr [1:8] "(Intercept)" "sex" "A" "sex:A" ... > $ repeated : logi TRUE > $ type : chr "III" > $ test : chr "Wilks" > $ idata :'data.frame': 6 obs. of 2 variables: > ..$ A: Factor w/ 2 levels "1","2": 1 1 1 2 2 2 > .. ..- attr(*, "contrasts")= chr "contr.sum" > ..$ B: Factor w/ 3 levels "1","2","3": 1 2 3 1 2 3 > .. ..- attr(*, "contrasts")= chr "contr.sum" > $ idesign :Class 'formula' length 2 ~A * B > .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> > $ icontrasts: chr [1:2] "contr.sum" "contr.poly" > $ imatrix : NULL > - attr(*, "class")= chr "Anova.mlm" > > str(summary(result)) > > Type III Repeated Measures MANOVA Tests: > > ------------------------------------------ > > Term: (Intercept) > > Response transformation matrix: > (Intercept) > a1_b1 1 > a1_b2 1 > a1_b3 1 > a2_b1 1 > a2_b2 1 > a2_b3 1 > > Sum of squares and products for the hypothesis: > (Intercept) > (Intercept) 1169345 > > Sum of squares and products for error: > (Intercept) > (Intercept) 34459.4 > > Multivariate Tests: (Intercept) > Df test stat approx F num Df den Df Pr(>F) > Pillai 1 0.97137 610.8117 1 18 2.425e-15 > Wilks 1 0.02863 610.8117 1 18 2.425e-15 > Hotelling-Lawley 1 33.93399 610.8117 1 18 2.425e-15 > Roy 1 33.93399 610.8117 1 18 2.425e-15 > > ------------------------------------------ > > Term: sex > > Response transformation matrix: > (Intercept) > a1_b1 1 > a1_b2 1 > a1_b3 1 > a2_b1 1 > a2_b2 1 > a2_b3 1 > > Sum of squares and products for the hypothesis: > (Intercept) > (Intercept) 10857.8 > > Sum of squares and products for error: > (Intercept) > (Intercept) 34459.4 > > Multivariate Tests: sex > Df test stat approx F num Df den Df Pr(>F) > Pillai 1 0.2395956 5.671614 1 18 0.028486 > Wilks 1 0.7604044 5.671614 1 18 0.028486 > Hotelling-Lawley 1 0.3150896 5.671614 1 18 0.028486 > Roy 1 0.3150896 5.671614 1 18 0.028486 > > ------------------------------------------ > > Term: A > > Response transformation matrix: > A1 > a1_b1 1 > a1_b2 1 > a1_b3 1 > a2_b1 -1 > a2_b2 -1 > a2_b3 -1 > > Sum of squares and products for the hypothesis: > A1 > A1 980 > > Sum of squares and products for error: > A1 > A1 10401.8 > > Multivariate Tests: A > Df test stat approx F num Df den Df Pr(>F) > Pillai 1 0.0861024 1.695860 1 18 0.20925 > Wilks 1 0.9138976 1.695860 1 18 0.20925 > Hotelling-Lawley 1 0.0942145 1.695860 1 18 0.20925 > Roy 1 0.0942145 1.695860 1 18 0.20925 > > ------------------------------------------ > > Term: sex:A > > Response transformation matrix: > A1 > a1_b1 1 > a1_b2 1 > a1_b3 1 > a2_b1 -1 > a2_b2 -1 > a2_b3 -1 > > Sum of squares and products for the hypothesis: > A1 > A1 0.2 > > Sum of squares and products for error: > A1 > A1 10401.8 > > Multivariate Tests: sex:A > Df test stat approx F num Df den Df Pr(>F) > Pillai 1 0.0000192 0.0003460939 1 18 0.98536 > Wilks 1 0.9999808 0.0003460939 1 18 0.98536 > Hotelling-Lawley 1 0.0000192 0.0003460939 1 18 0.98536 > Roy 1 0.0000192 0.0003460939 1 18 0.98536 > > ------------------------------------------ > > Term: B > > Response transformation matrix: > B1 B2 > a1_b1 1 0 > a1_b2 0 1 > a1_b3 -1 -1 > a2_b1 1 0 > a2_b2 0 1 > a2_b3 -1 -1 > > Sum of squares and products for the hypothesis: > B1 B2 > B1 3618.05 3443.2 > B2 3443.20 3276.8 > > Sum of squares and products for error: > B1 B2 > B1 2304.5 1396.8 > B2 1396.8 1225.2 > > Multivariate Tests: B > Df test stat approx F num Df den Df Pr(>F) > Pillai 1 0.730544 23.04504 2 17 1.4426e-05 > Wilks 1 0.269456 23.04504 2 17 1.4426e-05 > Hotelling-Lawley 1 2.711181 23.04504 2 17 1.4426e-05 > Roy 1 2.711181 23.04504 2 17 1.4426e-05 > > ------------------------------------------ > > Term: sex:B > > Response transformation matrix: > B1 B2 > a1_b1 1 0 > a1_b2 0 1 > a1_b3 -1 -1 > a2_b1 1 0 > a2_b2 0 1 > a2_b3 -1 -1 > > Sum of squares and products for the hypothesis: > B1 B2 > B1 26.45 23 > B2 23.00 20 > > Sum of squares and products for error: > B1 B2 > B1 2304.5 1396.8 > B2 1396.8 1225.2 > > Multivariate Tests: sex:B > Df test stat approx F num Df den Df Pr(>F) > Pillai 1 0.0160644 0.1387764 2 17 0.8714 > Wilks 1 0.9839356 0.1387764 2 17 0.8714 > Hotelling-Lawley 1 0.0163266 0.1387764 2 17 0.8714 > Roy 1 0.0163266 0.1387764 2 17 0.8714 > > ------------------------------------------ > > Term: A:B > > Response transformation matrix: > A1:B1 A1:B2 > a1_b1 1 0 > a1_b2 0 1 > a1_b3 -1 -1 > a2_b1 -1 0 > a2_b2 0 -1 > a2_b3 1 1 > > Sum of squares and products for the hypothesis: > A1:B1 A1:B2 > A1:B1 5152.05 738.3 > A1:B2 738.30 105.8 > > Sum of squares and products for error: > A1:B1 A1:B2 > A1:B1 3210.5 1334.4 > A1:B2 1334.4 924.0 > > Multivariate Tests: A:B > Df test stat approx F num Df den Df Pr(>F) > Pillai 1 0.7252156 22.43334 2 17 1.7039e-05 > Wilks 1 0.2747844 22.43334 2 17 1.7039e-05 > Hotelling-Lawley 1 2.6392162 22.43334 2 17 1.7039e-05 > Roy 1 2.6392162 22.43334 2 17 1.7039e-05 > > ------------------------------------------ > > Term: sex:A:B > > Response transformation matrix: > A1:B1 A1:B2 > a1_b1 1 0 > a1_b2 0 1 > a1_b3 -1 -1 > a2_b1 -1 0 > a2_b2 0 -1 > a2_b3 1 1 > > Sum of squares and products for the hypothesis: > A1:B1 A1:B2 > A1:B1 26.45 2.3 > A1:B2 2.30 0.2 > > Sum of squares and products for error: > A1:B1 A1:B2 > A1:B1 3210.5 1334.4 > A1:B2 1334.4 924.0 > > Multivariate Tests: sex:A:B > Df test stat approx F num Df den Df Pr(>F) > Pillai 1 0.0157232 0.1357821 2 17 0.87397 > Wilks 1 0.9842768 0.1357821 2 17 0.87397 > Hotelling-Lawley 1 0.0159744 0.1357821 2 17 0.87397 > Roy 1 0.0159744 0.1357821 2 17 0.87397 > > Univariate Type III Repeated-Measures ANOVA Assuming Sphericity > > SS num Df Error SS den Df F Pr(>F) > (Intercept) 194891 1 5743.2 18 610.8117 2.425e-15 > sex 1810 1 5743.2 18 5.6716 0.02849 > A 163 1 1733.6 18 1.6959 0.20925 > sex:A 0 1 1733.6 18 0.0003 0.98536 > B 1151 2 711.0 36 29.1292 2.990e-08 > sex:B 8 2 711.0 36 0.1979 0.82134 > A:B 1507 2 933.4 36 29.0532 3.078e-08 > sex:A:B 8 2 933.4 36 0.1565 0.85568 > > > Mauchly Tests for Sphericity > > Test statistic p-value > B 0.57532 0.0091036 > sex:B 0.57532 0.0091036 > A:B 0.45375 0.0012104 > sex:A:B 0.45375 0.0012104 > > > Greenhouse-Geisser and Huynh-Feldt Corrections > for Departure from Sphericity > > GG eps Pr(>F[GG]) > B 0.70191 2.143e-06 > sex:B 0.70191 0.7427 > A:B 0.64672 4.838e-06 > sex:A:B 0.64672 0.7599 > > HF eps Pr(>F[HF]) > B 0.74332 1.181e-06 > sex:B 0.74332 0.7560 > A:B 0.67565 3.191e-06 > sex:A:B 0.67565 0.7702 > List of 13 > $ SSP :List of 8 > ..$ (Intercept): num [1, 1] 1169345 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr "(Intercept)" > .. .. ..$ : chr "(Intercept)" > ..$ sex : num [1, 1] 10858 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr "(Intercept)" > .. .. ..$ : chr "(Intercept)" > ..$ A : num [1, 1] 980 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr "A1" > .. .. ..$ : chr "A1" > ..$ sex:A : num [1, 1] 0.2 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr "A1" > .. .. ..$ : chr "A1" > ..$ B : num [1:2, 1:2] 3618 3443 3443 3277 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:2] "B1" "B2" > .. .. ..$ : chr [1:2] "B1" "B2" > ..$ sex:B : num [1:2, 1:2] 26.4 23 23 20 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:2] "B1" "B2" > .. .. ..$ : chr [1:2] "B1" "B2" > ..$ A:B : num [1:2, 1:2] 5152 738 738 106 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > ..$ sex:A:B : num [1:2, 1:2] 26.4 2.3 2.3 0.2 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > $ SSPE :List of 8 > ..$ (Intercept): num [1, 1] 34459 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr "(Intercept)" > .. .. ..$ : chr "(Intercept)" > ..$ sex : num [1, 1] 34459 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr "(Intercept)" > .. .. ..$ : chr "(Intercept)" > ..$ A : num [1, 1] 10402 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr "A1" > .. .. ..$ : chr "A1" > ..$ sex:A : num [1, 1] 10402 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr "A1" > .. .. ..$ : chr "A1" > ..$ B : num [1:2, 1:2] 2304 1397 1397 1225 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:2] "B1" "B2" > .. .. ..$ : chr [1:2] "B1" "B2" > ..$ sex:B : num [1:2, 1:2] 2304 1397 1397 1225 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:2] "B1" "B2" > .. .. ..$ : chr [1:2] "B1" "B2" > ..$ A:B : num [1:2, 1:2] 3210 1334 1334 924 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > ..$ sex:A:B : num [1:2, 1:2] 3210 1334 1334 924 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > $ P :List of 8 > ..$ (Intercept): num [1:6, 1] 1 1 1 1 1 1 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... > .. .. ..$ : chr "(Intercept)" > ..$ sex : num [1:6, 1] 1 1 1 1 1 1 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... > .. .. ..$ : chr "(Intercept)" > ..$ A : num [1:6, 1] 1 1 1 -1 -1 -1 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... > .. .. ..$ : chr "A1" > ..$ sex:A : num [1:6, 1] 1 1 1 -1 -1 -1 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... > .. .. ..$ : chr "A1" > ..$ B : num [1:6, 1:2] 1 0 -1 1 0 -1 0 1 -1 0 ... > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... > .. .. ..$ : chr [1:2] "B1" "B2" > ..$ sex:B : num [1:6, 1:2] 1 0 -1 1 0 -1 0 1 -1 0 ... > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... > .. .. ..$ : chr [1:2] "B1" "B2" > ..$ A:B : num [1:6, 1:2] 1 0 -1 -1 0 1 0 1 -1 0 ... > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > ..$ sex:A:B : num [1:6, 1:2] 1 0 -1 -1 0 1 0 1 -1 0 ... > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : chr [1:6] "a1_b1" "a1_b2" "a1_b3" "a2_b1" ... > .. .. ..$ : chr [1:2] "A1:B1" "A1:B2" > $ df : Named num [1:8] 1 1 1 1 1 1 1 1 > ..- attr(*, "names")= chr [1:8] "(Intercept)" "sex" "A" "sex:A" ... > $ error.df : int 18 > $ terms : chr [1:8] "(Intercept)" "sex" "A" "sex:A" ... > $ repeated : logi TRUE > $ type : chr "III" > $ test : chr "Wilks" > $ idata :'data.frame': 6 obs. of 2 variables: > ..$ A: Factor w/ 2 levels "1","2": 1 1 1 2 2 2 > .. ..- attr(*, "contrasts")= chr "contr.sum" > ..$ B: Factor w/ 3 levels "1","2","3": 1 2 3 1 2 3 > .. ..- attr(*, "contrasts")= chr "contr.sum" > $ idesign :Class 'formula' length 2 ~A * B > .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> > $ icontrasts: chr [1:2] "contr.sum" "contr.poly" > $ imatrix : NULL > - attr(*, "class")= chr "Anova.mlm" > > result$`Pr(>F)` > NULL > > result[[4]] > (Intercept) sex A sex:A B sex:B > 1 1 1 1 1 1 > A:B sex:A:B > 1 1 > > > > > > > > > > Op 23/08/2010 21:56, Dennis Murphy schreef: >> Hi: >> >> Look at >> result$`Pr(>F)` >> >> (with backticks around Pr(>F) ), or more succinctly, result[[4]]. >> >> HTH, >> Dennis >> >> On Mon, Aug 23, 2010 at 12:01 PM, Johan Steen <johan.steen at gmail.com >> <mailto:johan.steen at gmail.com>> wrote: >> >> Dear all, >> >> is there anyone who can help me extracting p-values from an Anova >> object from the car library? I can't seem to locate the p-values >> using str(result) or str(summary(result)) in the example below >> >> > A <- factor( rep(1:2,each=3) ) >> > B <- factor( rep(1:3,times=2) ) >> > idata <- data.frame(A,B) >> > fit <- lm( cbind(a1_b1,a1_b2,a1_b3,a2_b1,a2_b2,a2_b3) ? sex, >> data=Data.wide) >> > result <- Anova(fit, type="III", test="Wilks", idata=idata, >> idesign=?A*B) >> >> >> Any help would be much appreciated! >> >> >> Many thanks, >> >> Johan >> >> ______________________________________________ >> R-help at r-project.org <mailto:R-help at r-project.org> mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >>
John Fox
2010-Aug-23 21:53 UTC
[R] extracting p-values from Anova objects (from the car library)
Dear Johan,> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]On> Behalf Of Johan Steen > Sent: August-23-10 3:02 PM > To: r-help at r-project.org > Subject: [R] extracting p-values from Anova objects (from the car library) > > Dear all, > > is there anyone who can help me extracting p-values from an Anova object > from the car library? I can't seem to locate the p-values using > str(result) or str(summary(result)) in the example below > > > A <- factor( rep(1:2,each=3) ) > > B <- factor( rep(1:3,times=2) ) > > idata <- data.frame(A,B) > > fit <- lm( cbind(a1_b1,a1_b2,a1_b3,a2_b1,a2_b2,a2_b3) ~ sex, > data=Data.wide) > > result <- Anova(fit, type="III", test="Wilks", idata=idata,idesign=~A*B)> > > Any help would be much appreciated!I'm afraid that the answer is that the p-values aren't easily accessible. The print method for Anova.mlm objects just passes through the object invisibly as its result, as is conventional for print methods. The summary method does the same -- that isn't conventional, but the summary method can produce so many different kinds of printed output (various multivariate test criteria for models with and without repeated measures; for the latter, multivariate and univariate tests with and without corrections for non-sphericity) that the printed output is produced directly rather than put in an object with its own print method. What you can do is take a look at car:::print.Anova.mlm or car:::summary.Anova.mlm (probably the print method, which is simpler) to see how the p-values that you want are computed and write a small function to return them. I hope this helps, John -------------------------------- John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox> > > Many thanks, > > Johan > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.