[R] MANOVA polynomial contrasts

John Fox jfox at mcmaster.ca
Tue Jul 31 00:55:38 CEST 2012


Dear Mauro,

I believe that I've answered a version of this question three times this
month alone, so I'll be brief.

 Are you aware that if you use type-III tests, even if you are careful to
employ contrasts, such as orthogonal polynomial contrasts, that are
orthogonal for different terms in the row-basis of the design, you will
nevertheless be testing for differences when the covariates are both 0? If
that's not sensible, then why not use type-II tests?

(As an aside, I've been experiencing a problem with my ISP that's causing my
return email address to be given incorrectly; please don't reply to an
address other than jfox at mcmaster.ca -- and, of course,
r-help at r-project.org.)

John

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of Manzoni, GianMauro
> Sent: July-30-12 5:21 PM
> To: jesse.fox at sympatico.ca
> Cc: r-help at r-project.org
> Subject: Re: [R] MANOVA polynomial contrasts
> 
> Dear Prof. John Fox,
> I found the paper very useful. Thank you very much for attaching the link!
> Which type of SS (II or III) do you suggest for a multivariate model with
2
> unbalanced factors and 2 covariates?
> I think that type III is the right one but ....
> 
> Mauro
> 
> 
> 
> 2012/7/30 <jesse.fox at sympatico.ca>
> 
> > Dear GMM,
> >
> > > -----Original Message-----
> > > From: Manzoni, GianMauro [mailto:gm.manzoni at auxologico.it]
> > > Sent: July-30-12 9:49 AM
> > > To: John Fox
> > > Cc: r-help at r-project.org; Greg Snow
> > > Subject: Re: [R] MANOVA polynomial contrasts
> > >
> > > Dear Prof. John Fox,
> > > thus all I should do to test quadratic and cubic effects is to
> > > change the
> > second
> > > argument of the linearHypothesis() function, right?
> > > So, for testing the cubic effect:
> > > >  linearHypothesis (mod, "f.C")
> >
> > Yes, but wouldn't it have been faster simply to try it? Also see
> > ?linearHypothesis.
> >
> > >
> > > Is there a chapter or paragragh about contrasts in your book "An R
> > > companion for applied regression"?
> >
> > There are discussions of contrasts and of linear hypotheses about
> > coefficients, though not in the context of *multivariate* linear
> > models; that's the subject of an on-line appendix, at <
> >
> >
> http://socserv.socsci.mcmaster.ca/jfox/Books/Companion/appendix/Appen
> d
> > ix-Mul
> > tivariate-Linear-Models.pdf>.
> >
> > Best,
> >  John
> >
> > >
> > > Best regards,
> > > GMM
> > >
> > > 2012/7/30 John Fox <jfox at mcmaster.ca>
> > >
> > >
> > >       Dear Gian Mauro,
> > >
> > >
> > >       On Mon, 30 Jul 2012 14:44:44 +0200
> > >        "Manzoni, GianMauro" <gm.manzoni at auxologico.it> wrote:
> > >       > Dear Prof. John Fox,
> > >       > thank you very much for your suggestions.
> > >       > However, I still do not know how to use the contrasts after
> > > generating them.
> > >       > Once I generate the matrix with the polynomial contrasts,
> > > what
> > are
> > > the
> > >       > following steps toward the statistical test?
> > >
> > >
> > >       Here's a contrived example, which uses the Anova() and
> > > linearHypothesis() functions in the car package:
> > >
> > >       ----- snip ------
> > >
> > >       > Y <- matrix(rnorm(300), 100, 3)
> > >       > colnames(Y) <- c("y1", "y2", "y3")
> > >       > f <- ordered(sample(letters[1:4], 100, replace=TRUE))
> > >       > (mod <- lm(Y ~ f))
> > >
> > >       Call:
> > >       lm(formula = Y ~ f)
> > >
> > >       Coefficients:
> > >                    y1        y2        y3
> > >       (Intercept)   0.06514  -0.01683  -0.13787
> > >       f.L          -0.37837   0.18309   0.29736
> > >       f.Q          -0.02102  -0.39894   0.08455
> > >       f.C           0.05898   0.09358  -0.17634
> > >
> > >       > Anova(mod)
> > >
> > >       Type II MANOVA Tests: Pillai test statistic
> > >         Df test stat approx F num Df den Df Pr(>F)
> > >       f  3   0.11395   1.2634      9    288 0.2566
> > >
> > >       > linearHypothesis(mod, "f.L")
> > >
> > >       Sum of squares and products for the hypothesis:
> > >                 y1        y2        y3
> > >       y1  3.607260 -1.745560 -2.834953
> > >       y2 -1.745560  0.844680  1.371839
> > >       y3 -2.834953  1.371839  2.227995
> > >
> > >       Sum of squares and products for error:
> > >                 y1        y2        y3
> > >       y1 86.343376 -8.054928 -3.711756
> > >       y2 -8.054928 95.473020  2.429151
> > >       y3 -3.711756  2.429151 89.593163
> > >
> > >       Multivariate Tests:
> > >                        Df test stat approx F num Df den Df   Pr(>F)
> > >       Pillai            1 0.0648520 2.172951      3     94 0.096362 .
> > >       Wilks             1 0.9351480 2.172951      3     94 0.096362 .
> > >       Hotelling-Lawley  1 0.0693495 2.172951      3     94 0.096362 .
> > >       Roy               1 0.0693495 2.172951      3     94 0.096362 .
> > >       ---
> > >       Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> > >
> > >       ----- snip ------
> > >
> > >       You could do similar tests for the quadratic and cubic
contrasts.
> > >
> > >       I hope this helps,
> > >
> > >        John
> > >
> > >       ------------------------------------------------
> > >       John Fox
> > >       Sen. William McMaster Prof. of Social Statistics
> > >       Department of Sociology
> > >       McMaster University
> > >       Hamilton, Ontario, Canada
> > >       http://socserv.mcmaster.ca/jfox/
> > >
> > >       >
> > >       > A whole example would be very useful.
> > >       >
> > >       > Thank you very much in advance!
> > >       >
> > >       > Best regards,
> > >       > Gian Mauro Manzoni
> > >       >
> > >       >
> > >       >
> > >       > 2012/7/25 John Fox <jfox at mcmaster.ca>
> > >       >
> > >       > > Dear Gian,
> > >       > >
> > >       > > How contrasts are created by default is controlled by the
> > > contrasts option:
> > >       > >
> > >       > > > getOption("contrasts")
> > >       > >         unordered           ordered
> > >       > > "contr.treatment"      "contr.poly"
> > >       > >
> > >       > > So, unless you've changed this option, contr.poly() will
> > > be
> > used
> > to
> > >       > > generate orthogonal polynomial contrasts for an ordered
> > > factor, and you
> > >       > > therefore need do nothing special to get this result. For
> > example:
> > >       > >
> > >       > > > (f <- ordered(sample(letters[1:3], 10, replace=TRUE)))
> > >       > >  [1] c c a a c c b c a c
> > >       > > Levels: a < b < c
> > >       > >
> > >       > > > round(contrasts(f), 4)
> > >       > >           .L      .Q
> > >       > > [1,] -0.7071  0.4082
> > >       > > [2,]  0.0000 -0.8165
> > >       > > [3,]  0.7071  0.4082
> > >       > >
> > >       > > For more information, see section 11 on statistical models
> > > in
> > the
> > > manual
> > >       > > "An Introduction to R," which is part of the standard R
> > > distribution, and
> > >       > > in particular sections 11.1 and 11.1.1.
> > >       > >
> > >       > > I hope that this clarifies the issue.
> > >       > >
> > >       > > Best,
> > >       > >  John
> > >       > >
> > >       > > ------------------------------------------------
> > >       > > John Fox
> > >       > > Sen. William McMaster Prof. of Social Statistics
> > >       > > Department of Sociology
> > >       > > McMaster University
> > >       > > Hamilton, Ontario, Canada
> > >       > > http://socserv.mcmaster.ca/jfox/
> > >       > >
> > >       > > On Wed, 25 Jul 2012 11:58:30 +0200
> > >       > >  "Manzoni, GianMauro" <gm.manzoni at auxologico.it> wrote:
> > >       > > > Dear Greg Snow,
> > >       > > > thank you very much for your suggestions. However, I
> > > need an example in
> > >       > > > order to understand fully.
> > >       > > > I was told that, given the ordinal factor, I do not need
> > > to
> > specify
> > > the
> > >       > > > contr.poly function because R does it automatically.
> > >       > > > However, I don not know if I have to add an argument into
the
> > >       > > manova/anova
> > >       > > > function or something else.
> > >       > > > Please write me an illustrative example.
> > >       > > > Many thanks.
> > >       > > >
> > >       > > > Best regards,
> > >       > > > Gian Mauro Manzoni
> > >       > > >
> > >       > > > 2012/7/25 Greg Snow <538280 at gmail.com>
> > >       > > >
> > >       > > > > You should not need to write them yourself. Look at
> > > the contr.poly
> > >       > > > > function along with the C function (Note uppercase C)
> > > or
> > the
> > > contrasts
> > >       > > > > function.
> > >       > > > >
> > >       > > > >
> > >       > > > > On Monday, July 23, 2012, Manzoni, GianMauro wrote:
> > >       > > > >
> > >       > > > >> Dear all,
> > >       > > > >> I am quite new to R and I am having trouble writing
> > > the polynomial
> > >       > > > >> contrasts for an ordinal factor in MANOVA.
> > >       > > > >> # I have a model such as this
> > >       > > > >> fit<-manova(cbind(Y1,Y2,Y3)~Groups,data=Events) #
> > > where groups is an
> > >       > > > >> ordinal factor with 4 levels
> > >       > > > >> # how to set polynomial contrasts for the "Groups"
> > > factor
> > ?
> > >       > > > >>
> > >       > > > >> Thank you very much in advance for any help!
> > >       > > > >>
> > >       > > > >> Best regards,
> > >       > > > >> Mauro
> > >       > > > >>
> > >       > > > >> --
> > >       > > > >> Dr. Gian Mauro Manzoni
> > >       > > > >> PhD, PsyD
> > >       > > > >> Psychology Research Laboratory
> > >       > > > >> San Giuseppe Hospital
> > >       > > > >> Istituto Auxologico Italiano
> > >       > > > >> Verbania - Italy
> > >       > > > >> e-mail: gm.manzoni at auxologico.it
> > >       > > > >> cell. phone +39 338 4451207 <tel:%2B39%20338%204451207>
> > >       > > > >> Tel. +39 0323 514278 <tel:%2B39%200323%20514278>
> > >       > > > >>
> > >       > > > >>         [[alternative HTML version deleted]]
> > >       > > > >>
> > >       > > > >> ______________________________________________
> > >       > > > >> 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.
> > >       > > > >>
> > >       > > > >
> > >       > > > >
> > >       > > > > --
> > >       > > > > Gregory (Greg) L. Snow Ph.D.
> > >       > > > > 538280 at gmail.com
> > >       > > > >
> > >       > > >
> > >       > > >
> > >       > > >
> > >       > > > --
> > >       > > > Dr. Gian Mauro Manzoni
> > >       > > > PhD, PsyD
> > >       > > > Psychology Research Laboratory
> > >       > > > San Giuseppe Hospital
> > >       > > > Istituto Auxologico Italiano
> > >       > > > Verbania - Italy
> > >       > > > e-mail: gm.manzoni at auxologico.it
> > >       > > > cell. phone +39 338 4451207 <tel:%2B39%20338%204451207>
> > >       > > > Tel. +39 0323 514278 <tel:%2B39%200323%20514278>
> > >       > > >
> > >       > > >       [[alternative HTML version deleted]]
> > >       > > >
> > >       > > > ______________________________________________
> > >       > > > 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.
> > >       > >
> > >       > >
> > >       > >
> > >       >
> > >       >
> > >       > --
> > >       > Dr. Gian Mauro Manzoni
> > >       > PhD, PsyD
> > >       > Psychology Research Laboratory
> > >       > San Giuseppe Hospital
> > >       > Istituto Auxologico Italiano
> > >       > Verbania - Italy
> > >       > e-mail: gm.manzoni at auxologico.it
> > >       > cell. phone +39 338 4451207 <tel:%2B39%20338%204451207>
> > >       > Tel. +39 0323 514278 <tel:%2B39%200323%20514278>
> > >
> > >
> > >
> > >
> > >
> > > --
> > > Dr. Gian Mauro Manzoni
> > > PhD, PsyD
> > > Psychology Research Laboratory
> > > San Giuseppe Hospital
> > > Istituto Auxologico Italiano
> > > Verbania - Italy
> > > e-mail: gm.manzoni at auxologico.it
> > > cell. phone +39 338 4451207
> > > Tel. +39 0323 514278
> >
> >
> >
> 
> 
> --
> Dr. Gian Mauro Manzoni
> PhD, PsyD
> Psychology Research Laboratory
> San Giuseppe Hospital
> Istituto Auxologico Italiano
> Verbania - Italy
> e-mail: gm.manzoni at auxologico.it
> cell. phone +39 338 4451207
> Tel. +39 0323 514278
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.



More information about the R-help mailing list