[R] step() and stepAIC()

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Oct 12 08:47:33 CEST 2008


On Sun, 12 Oct 2008, Murray Jorgensen wrote:

> The birth weight example from ?stepAIC in package MASS runs well as
> indeed it should.
>
> However when I change stepAIC() calls to step() calls I get warning
> messages that I don't understand, although the output is similar.

Why would you do this?

> Warning messages:
> 1: In model.response(m, "numeric") :
>  using type="numeric" with a factor response will be ignored
> (and three more the same.)

I presume you did

library(MASS)
example(birthwt)
birthwt.glm <- glm(low ~ ., family = binomial, data = bwt)
birthwt.step <- step(birthwt.glm, trace = FALSE)
birthwt.step$anova
birthwt.step2 <- step(birthwt.glm, ~ .^2 + I(scale(age)^2)
     + I(scale(lwt)^2), trace = FALSE)
birthwt.step2$anova

and are referrring to the second call?

> Checked with 2.7.0 on Os X and 2.6.2 on Windows.

Those are not current versions.  But the difference is that stepAIC uses 
addterm and step uses add1, and this is a (harmless) infelicity in 
add1.glm.

>
> Cheers,  Murray
> -- 
> Dr Murray Jorgensen      http://www.stats.waikato.ac.nz/Staff/maj.html
> Department of Statistics, University of Waikato, Hamilton, New Zealand
> Email: maj at waikato.ac.nz                                Fax 7 838 4155
> Phone  +64 7 838 4773 wk    Home +64 7 825 0441    Mobile 021 1395 862
>
> ______________________________________________
> 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.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list