[R] performing type III

John Fox jfox at mcmaster.ca
Fri Mar 12 14:45:21 CET 2004


Dear Hardouin,

It has already been mentioned that the Anova() function in the car package
has a name beginning with an uppercase "A".

There are some other problems here as well:

(1) Unless you've written a contrasts function called sum(), and even if you
have, contrasts=sum isn't going to do anything. The contrasts argument is
supposed to be a list. See ?lm and ?contr.sum.

(2) The Anova() function in the car library doesn't calculate "type-I" sums
of squares; you can use anova() for this -- as you've done inadvertently.

(3) The type argument to the Anova() function takes *one* of "II" or "III"
as a value. See ?Anova.

(4) You describe this as an analysis of covariance. Type III sums of squares
for the "main" effects won't be sensible here unless the covariates are
expressed as deviations from their means (or some other reference point).

John

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Hardouin Loïc
> Sent: Friday, March 12, 2004 3:46 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] performing type III
> 
> 
> Sorry to have not precised that I used the anova function in 
> the car package but I did.
> I try to fit clutch size with two covariables and a factor 
> (with two levels). My purpose is to compare results with type 
> I and III sum of squares and furhter perform model 
> simplification. The data set contains no missing value.
> The model run and provided only type I response with the 
> warning message (see below)
> 
>  > sq<-lm(tponte~logavril*reldponte*exp,data=wa,contrasts=sum)
>  > anova(sq,type=c("I","III"))
> Analysis of Variance Table
> 
> Response: tponte
>                        Df Sum Sq Mean Sq F value    Pr(>F) 
>  logavril                 1 27.930  27.930 52.5041 1.385e-11 ***
> reldponte                1 23.442  23.442 44.0670 3.984e-10 ***
> exp                      1  2.657   2.657  4.9940   0.02672 *
> logavril:reldponte       1  0.281   0.281  0.5292   0.46795  
> logavril:exp             1  0.925   0.925  1.7383   0.18911 
> reldponte:exp            1  0.016   0.016  0.0307   0.86105  
> logavril:reldponte:exp   1  1.052   1.052  1.9771   0.16150  
> Residuals              172 91.497   0.532                     ---
>  
> Warning message:
> Models with response "NULL" removed because response differs 
> from model
> 1 in: anova.lmlist(object, ...)
>  >
> 
> Hope to be clearer,
> Thanks,
> 
> Alex
> 
> >  
> >
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html




More information about the R-help mailing list