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")

Is there a chapter or paragragh about contrasts in your book "An R
companion for applied regression"?

Best regards,
GMM

2012/7/30 John Fox <jfox@mcmaster.ca>

> Dear Gian Mauro,
>
> On Mon, 30 Jul 2012 14:44:44 +0200
>  "Manzoni, GianMauro" <gm.manzoni@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@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@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@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@auxologico.it
> > > > >> cell. phone +39 338 4451207
> > > > >> Tel. +39 0323 514278
> > > > >>
> > > > >>         [[alternative HTML version deleted]]
> > > > >>
> > > > >> ______________________________________________
> > > > >> 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.
> > > > >>
> > > > >
> > > > >
> > > > > --
> > > > > Gregory (Greg) L. Snow Ph.D.
> > > > > 538280@gmail.com
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Dr. Gian Mauro Manzoni
> > > > PhD, PsyD
> > > > Psychology Research Laboratory
> > > > San Giuseppe Hospital
> > > > Istituto Auxologico Italiano
> > > > Verbania - Italy
> > > > e-mail: gm.manzoni@auxologico.it
> > > > cell. phone +39 338 4451207
> > > > Tel. +39 0323 514278
> > > >
> > > >       [[alternative HTML version deleted]]
> > > >
> > > > ______________________________________________
> > > > 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.
> > >
> > >
> > >
> >
> >
> > --
> > Dr. Gian Mauro Manzoni
> > PhD, PsyD
> > Psychology Research Laboratory
> > San Giuseppe Hospital
> > Istituto Auxologico Italiano
> > Verbania - Italy
> > e-mail: gm.manzoni@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@auxologico.it
cell. phone +39 338 4451207
Tel. +39 0323 514278

	[[alternative HTML version deleted]]

