Re: [R] Doing partial-f test for stepwise regression

From: <rolf_at_math.unb.ca>
Date: Sun 01 Apr 2007 - 14:06:26 GMT


Petr Klasterecky <klaster@karlin.mff.cuni.cz> wrote:

> And what about to read the help page ?anova ...?
>
> >>>
> When given a sequence of objects, 'anova' tests the models against
> one another in the order specified.
> <<<

        One perfectly reasonable response to ``what about'' is
        that it is not *at all* clear as to what the statement
        in the help page actually means.

> Generally you almost never fit a full model (including all possible
> interactions etc) - no one can interpret such complicated models.

        This assertion is certainly open to some dispute.

> Anova gives you a comparison between a broader model (the first
> argument to anova) and its submodel(s).

        As I read the above statement, it seems you've got
        it exactly backwards.  Broader model == full model,
        submodel = model under the null hypothesis, is it
        not so?

	You should actually specify the ``reduced'' model (the model
	under the null hypothesis) first, and the full model second.
	E.g.:

         > y <- runif(20)
         > x1 <- runif(20)
         > x2 <- runif(20)
         > x3 <- runif(20)
         > f1 <- lm(y~x1+x2+x3)
         > f2 <- lm(y~x1)
         > anova(f1,f2)
        Analysis of Variance Table

        Model 1: y ~ x1 + x2 + x3
        Model 2: y ~ x1
           Res.Df      RSS Df Sum of Sq      F Pr(>F)
        1     16  0.93225                           
        2     18  1.07998 -2  -0.14774 1.2678 0.3083

        Doing it your way --- full model first --- gives a
        negative sum of squares.  And negative degrees of
        freedom for the effect being tested.

        Not that it really matters --- the anova() function
        gives you the same F statistic and p-value either way.
        And the negative SS is a dead giveaway that something
        is a bit skew-wiff.

                                cheers,

                                        Rolf Turner
                                        rolf@math.unb.ca

______________________________________________
R-help@stat.math.ethz.ch 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. Received on Mon Apr 02 00:12:25 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 01 Apr 2007 - 15:30:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.