Michael Rennie
2008-Jul-15 15:09 UTC
[R] extracting elements from print object of Manova()
Hi there, Does anyone know how to extract elements from the table returned by Manova()? Using the univariate equivalent, Anova(), it's easy: a.an<-Anova(lm(y~x1*x2)) a.an$F This will return a vector of the F-values in order of the terms of the model. However, a similar application using Manova(): m.an<-Manova(lm(Y~x1~x2)) m.an$F Returns NULL. So does any attempt at calling the headers in the MANOVA table. Any thoughts? Mike -- -- Michael D. Rennie Ph.D. Candidate University of Toronto at Mississauga 3359 Missisagua Rd. N. Mississauga, ON L5L 1C6 Ph: 905-828-5452 Fax: 905-828-3792 www.utm.utoronto.ca/~w3rennie
Jorge Ivan Velez
2008-Jul-15 18:43 UTC
[R] extracting elements from print object of Manova()
Dear Michael, Does it work for you? tear <- c(6.5, 6.2, 5.8, 6.5, 6.5, 6.9, 7.2, 6.9, 6.1, 6.3, 6.7, 6.6, 7.2, 7.1, 6.8, 7.1, 7.0, 7.2, 7.5, 7.6) gloss <- c(9.5, 9.9, 9.6, 9.6, 9.2, 9.1, 10.0, 9.9, 9.5, 9.4, 9.1, 9.3, 8.3, 8.4, 8.5, 9.2, 8.8, 9.7, 10.1, 9.2) opacity <- c(4.4, 6.4, 3.0, 4.1, 0.8, 5.7, 2.0, 3.9, 1.9, 5.7, 2.8, 4.1, 3.8, 1.6, 3.4, 8.4, 5.2, 6.9, 2.7, 1.9) Y <- cbind(tear, gloss, opacity) rate <- factor(gl(2,10), labels=c("Low", "High")) additive <- factor(gl(2, 5, length=20), labels=c("Low", "High")) # The model fit <- manova(Y ~ rate * additive) fit Call: manova(Y ~ rate * additive) Terms: rate additive rate:additive Residuals resp 1 1.7405 0.7605 0.0005 1.7640 resp 2 1.3005 0.6125 0.5445 2.6280 resp 3 0.4205 4.9005 3.9605 64.9240 Deg. of Freedom 1 1 1 16 Residual standard error: 0.3320392 0.4052777 2.014386 Estimated effects may be unbalanced # Analysis of Variance (table), names and F statistic anova(fit) Analysis of Variance Table Df Pillai approx F num Df den Df Pr(>F) (Intercept) 1 1.0 5950.9 3 14 < 2.2e-16 *** rate 1 0.6 7.6 3 14 0.003034 ** additive 1 0.5 4.3 3 14 0.024745 * rate:additive 1 0.2 1.3 3 14 0.301782 Residuals 16 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 names(anova(fit)) [1] "Df" "Pillai" "approx F" "num Df" "den Df" "Pr(>F)" anova(fit)["approx F"] approx F (Intercept) 5950.9 rate 7.6 additive 4.3 rate:additive 1.3 Residuals See ?summary.manova for more information. HTH, Jorge On Tue, Jul 15, 2008 at 11:09 AM, Michael Rennie <mdrennie@gmail.com> wrote:> Hi there, > > Does anyone know how to extract elements from the table returned by > Manova()? > > Using the univariate equivalent, Anova(), it's easy: > > a.an<-Anova(lm(y~x1*x2)) > > a.an$F > > This will return a vector of the F-values in order of the terms of the > model. > > However, a similar application using Manova(): > > m.an<-Manova(lm(Y~x1~x2)) > > m.an$F > > Returns NULL. So does any attempt at calling the headers in the MANOVA > table. > > Any thoughts? > > Mike > -- > -- > Michael D. Rennie > Ph.D. Candidate > University of Toronto at Mississauga > 3359 Missisagua Rd. N. > Mississauga, ON L5L 1C6 > Ph: 905-828-5452 Fax: 905-828-3792 > www.utm.utoronto.ca/~w3rennie <http://www.utm.utoronto.ca/%7Ew3rennie> > > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]
Michael Friendly
2008-Jul-16 15:00 UTC
[R] extracting elements from print object of Manova()
Michael, If you mean Manova in the car package (or manova in stats), just use str() on the resulting object to see the slots. However, Manova() doesn't return F values, since these depend on the type of test statistic used for the multivariate test. > library(car) > ?Manova > soils.mod <- lm(cbind(pH,N,Dens,P,Ca,Mg,K,Na,Conduc) ~ Block + Contour*Depth, + data=Soils) > man <-Manova(soils.mod) > str(man) List of 8 $ SSP :List of 4 ..$ Block : num [1:9, 1:9] 1.2325 -0.0466 0.2716 -62.6558 -0.6192 ... .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:9] "pH" "N" "Dens" "P" ... .. .. ..$ : chr [1:9] "pH" "N" "Dens" "P" ... ..$ Contour : num [1:9, 1:9] 0.2607 -0.0172 0.1002 23.9644 -1.5842 ... .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:9] "pH" "N" "Dens" "P" ... .. .. ..$ : chr [1:9] "pH" "N" "Dens" "P" ... ..$ Depth : num [1:9, 1:9] 14.96 1.45 -4.30 1703.12 74.47 ... .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:9] "pH" "N" "Dens" "P" ... .. .. ..$ : chr [1:9] "pH" "N" "Dens" "P" ... ..$ Contour:Depth: num [1:9, 1:9] 0.5159 0.0137 0.0457 -30.9419 1.5070 ... .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : chr [1:9] "pH" "N" "Dens" "P" ... .. .. ..$ : chr [1:9] "pH" "N" "Dens" "P" ... $ SSPE : num [1:9, 1:9] 4.247 -0.049 -0.201 -118.777 9.368 ... ..- attr(*, "dimnames")=List of 2 .. ..$ : chr [1:9] "pH" "N" "Dens" "P" ... .. ..$ : chr [1:9] "pH" "N" "Dens" "P" ... $ df : Named num [1:4] 3 2 3 6 ..- attr(*, "names")= chr [1:4] "Block" "Contour" "Depth" "Contour:Depth" $ error.df: int 33 $ terms : chr [1:4] "Block" "Contour" "Depth" "Contour:Depth" $ repeated: logi FALSE $ type : chr "II" $ test : chr "Pillai" - attr(*, "class")= chr "Anova.mlm" Michael Rennie wrote:> Hi there, > > Does anyone know how to extract elements from the table returned by Manova()? > > Using the univariate equivalent, Anova(), it's easy: > > a.an<-Anova(lm(y~x1*x2)) > > a.an$F > > This will return a vector of the F-values in order of the terms of the model. > > However, a similar application using Manova(): > > m.an<-Manova(lm(Y~x1~x2)) > > m.an$F > > Returns NULL. So does any attempt at calling the headers in the MANOVA table. > > Any thoughts? > > Mike-- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Street http://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA