Anova Type 1, 2 and 3 in Statsmodel.Anova_lm

1,383 views
Skip to first unread message

apu...@gmail.com

unread,
Mar 4, 2018, 3:53:16 PM3/4/18
to pystatsmodels
Hi

Can anyone explain what are type 1 2 and 3 in anova_lm (see below)?

I checked the notes in the Statsmodel anova section and also went to the Stats 191 lecture notes which this module is based on, but couldn't find any definition of Anova type 1, 2 and 3. Can anyone provide the info?

Thanks in advance.

Wai Leong
===
anova_lm(*args, **kwargs)
    ANOVA table for one or more fitted linear models.
   
    Parameters
    ----------
    args : fitted linear model results instance
        One or more fitted linear models
    scale : float
        Estimate of variance, If None, will be estimated from the largest
        model. Default is None.
    test : str {"F", "Chisq", "Cp"} or None
        Test statistics to provide. Default is "F".
    typ : str or int {"I","II","III"} or {1,2,3}
        The type of ANOVA test to perform. See notes.
    robust : {None, "hc0", "hc1", "hc2", "hc3"}
        Use heteroscedasticity-corrected coefficient covariance matrix.
        If robust covariance is desired, it is recommended to use `hc3`

josef...@gmail.com

unread,
Mar 4, 2018, 5:34:39 PM3/4/18
to pystatsmodels
On Sun, Mar 4, 2018 at 9:52 AM, <apu...@gmail.com> wrote:
Hi

Can anyone explain what are type 1 2 and 3 in anova_lm (see below)?

I checked the notes in the Statsmodel anova section and also went to the Stats 191 lecture notes which this module is based on, but couldn't find any definition of Anova type 1, 2 and 3. Can anyone provide the info?

I'm not sure. Last time I looked at it, I misunderstood again. (I try to stay away from it as much as possible.)

e.g. comments starting here
https://github.com/statsmodels/statsmodels/issues/3910#issuecomment-328213988
unfortunately the link there doesn't work for me anymore
another standard reference is the SAS documentation.

Josef

josef...@gmail.com

unread,
Mar 4, 2018, 6:35:06 PM3/4/18
to pystatsmodels
"If you sum the type III SS in an ANOVA table, you will notice that they do not equal the total SS. In other words, this analysis must be wrong "
https://stats.stackexchange.com/questions/20452/how-to-interpret-type-i-type-ii-and-type-iii-anova-and-manova

If explanatory variables are correlated, i.e. we don't have a balanced orthogonal design, then you can force a SS decomposition by choosing an arbitrary type 1 sequence. If  we don't want to arbitrarily assign the correlated or common part to one variable or a fixed sequence of variables, then we can look at marginal contributions of one term given all other terms in the model, which is type 2 for main effects (ignoring interaction effects, AFAIU)  or main effects and interaction effects separately in type 3 anova.


(or use some variation, type 4, type 2.5 ?)

Josef

Reply all
Reply to author
Forward
0 new messages