Dear John
On Tue, 9 Oct 2012 02:07:07 +0000
"John Jay Wiley Jr." <jwileyjr at syr.edu>
wrote:> I am working with a RCB 2x2x3 ANCOVA, and I have noticed a difference in
the calculation of sum of squares in a Type III calculation.
For type III tests, you should use contrasts that are orthogonal in the row
basis of the design. Perhaps you've done that (by setting the contrasts for
the factors directly), but I suspect not. Why not just use type II tests?
They're hard to screw up.
As well, I assume that the variables that enter additively are the covariates.
If not, and a covariate is involved in the interaction, the type III tests
aren't sensible unless the 0 point of the covariate is where you want to
test a "main effect" or lower-order interaction.
>
> Anova output is a follows:
>
> > Anova(aov(MSOIL~Forest+Burn*Thin*Moisture+ROCK,data=env3l),type=3)
> Anova Table (Type III tests)
>
> Response: MSOIL
> Sum Sq Df F value Pr(>F)
> (Intercept) 22.3682 1 53.2141 3.499e-07 ***
> Forest 1.0954 2 1.3029 0.29282
> Burn 2.6926 1 6.4058 0.01943 *
> Thin 0.0494 1 0.1176 0.73503
> Moisture 1.2597 2 1.4984 0.24644
> ROCK 2.1908 1 5.2119 0.03296 *
> Burn:Thin 0.2002 1 0.4764 0.49763
> Burn:Moisture 1.0612 2 1.2623 0.30360
> Thin:Moisture 1.6590 2 1.9734 0.16392
> Burn:Thin:Moisture 1.1175 2 1.3292 0.28605
> Residuals 8.8272 21
>
>
> However, I would like to calculate some a priori contrasts within the
Moisture factor as follows:
>
> Transect_moisture_contrasts<-matrix(c(-1,2,-1,1,0,-1),3,2)
>
dimnames(Transect_moisture_contrasts)<-list(levels(env$Moisture),c("I
vs. X&M","X vs. M"))
> contrasts(env$Moisture)<-Transect_moisture_contrasts
> > contrasts(env3l$Moisture)
> I vs. X&M X vs. M
> X -1 1
> I 2 0
> M -1 -1
>
>
> soilmodel<-lm(MSOIL~Forest+Burn*Thin*Moisture+ROCK,data=env3l)
> > linearHypothesis(soilmodel,"MoistureI vs. X&M")
> Linear hypothesis test
>
> Hypothesis:
> MoistureI vs. X&M = 0
>
> Model 1: restricted model
> Model 2: MSOIL ~ Forest + Burn * Thin * Moisture + ROCK
>
> Res.Df RSS Df Sum of Sq F Pr(>F)
> 1 22 9.4106
> 2 21 8.8272 1 0.58333 1.3877 0.252
> > linearHypothesis(soilmodel,"MoistureX vs. M")
> Linear hypothesis test
>
> Hypothesis:
> MoistureX vs. M = 0
>
> Model 1: restricted model
> Model 2: MSOIL ~ Forest + Burn * Thin * Moisture + ROCK
>
> Res.Df RSS Df Sum of Sq F Pr(>F)
> 1 22 9.6359
> 2 21 8.8272 1 0.80871 1.9239 0.18
>
> The sum of squares for these two contrasts do not add up to the sum of
squares of the main effect Moisture
> > .80871+.58333
> [1] 1.39204
> > 1.39204-1.2596
> [1] 0.13244
>
> Checking them together produces the correct sum of squares for the main
effect
> > linearHypothesis(soilmodel,c("MoistureI vs.
X&M","MoistureX vs. M"))
> Linear hypothesis test
>
> Hypothesis:
> MoistureI vs. X&M = 0
> MoistureX vs. M = 0
>
> Model 1: restricted model
> Model 2: MSOIL ~ Forest + Burn * Thin * Moisture + ROCK
>
> Res.Df RSS Df Sum of Sq F Pr(>F)
> 1 23 10.0869
> 2 21 8.8272 2 1.2596 1.4984 0.2464
>
>
> So my question is:
> Should the sum of squares for the two contrasts add to the main effect
here?
Only if the data are balanced.
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/
> If they should, maybe we can figure out why mine do not.
>
> Thanks in advance for any assistance.
>
> Cheers,
> John
>
>
> John J. Wiley, Jr.
> PhD Candidate
> State University of New York
> College of Environmental Science and Forestry
> Department of Environmental and Forest Biology
> 460 Illick Hall
> Syracuse, NY 13210
> 315.470.4825 (office)
> 740.590.6121 (cell)
>
> [[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.