[R] step() and stepAIC()

Murray Jorgensen maj at stats.waikato.ac.nz
Sun Oct 12 09:00:41 CEST 2008



Prof Brian Ripley wrote:
> 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?

I did this because I was originally following the code in V&R edition 2.
(I know, I know, I should have upgraded!)


> 
>> 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.
>>
> 

-- 
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    majorgensen at ihug.co.nz      Fax 7 838 4155
Phone  +64 7 838 4773 wk    Home +64 7 825 0441    Mobile 021 139 5862



More information about the R-help mailing list