[R] model selection with step function
Antonio Olinto
aolinto_r at bignet.com.br
Fri Nov 25 12:47:38 CET 2005
Dear Ehlers, thanks for your message.
Following the example on stepAIC and Venebles & Ripleys book, it seems that
update rearranges the terms. I didnt understand how to indicate the formula in
the function.
I have the initial model U ~ var1+var2+var3+var4 (family Gaussian). I want first
to select the terms, putting main effects first. If I just write step(model) it
will take out no significant variables (lets say var2) and will give U ~
var1+var3+var4. Supposing the var4 have the strongest effect upon U, followed
by var1 and var3, I would like to have the out put U ~ var4+var1+var2.
Is it possible to do so?
Thanks again.
Antonio Olinto
Biologist
Sao Paulo Fisheries Institute
PS. Unfortunately I dont have Regression Modeling Strategies around here
Citando P Ehlers <ehlers at math.ucalgary.ca>:
>
> Antonio Olinto wrote:
>
> > Hello,
> >
> > I have a doubt in using the function step (step wise) to select glm
> models.
> >
> > Usually I apply the gamma distribution to analyze fishery data. To select
> the
> > terms I use a routine where I first compare single term models to the null
> model
> > (eg. U~1 vs. U~depth; U~1 vs. U~latitude; etc. where U= abundance) and,
> by
> > means of the result given by a likelihook function applied for each
> comparison,
> > I select the strongest effect, lets say depth. Then I run a new step
> > comparing the U~depth vs. U~depth+latitude; U~depth vs. U~depth+... etc.
> Making
> > this way I put the terms in magnitude order.
> >
> > I tried to make a gaussian model using the step(glm.model) function to
> select
> > the terms but I saw that in the output table given by anova(glm.model) the
> > selected terms kept the original order.
> >
> > Is it possible to have the terms in the model rearranged, as in my
> example?
> >
> > Thanks for any help. I read Chambers and Hasties Statistical Models in
> S,
> > Venables and Ripley Modern Applied Statistics and, of course, R help but
> I
> > couldnt get the trick.
> >
>
> I don't know if this will get you there, but
>
> 1. I would use stepAIC in package MASS;
> 2. set argument trace = TRUE;
> 3. think very hard about the interpretation of the model;
> 4. read also Frank Harrell's "Regression Modeling Strategies".
>
> Peter
>
>
> > Antonio
> >
> > --
> > Biologist
> > Sao Paulo Fisheries Institute
> >
> >
> >
> > -------------------------------------------------
> > WebMail Bignet - O seu provedor do litoral
> > www.bignet.com.br
> >
> > ______________________________________________
> > R-help at 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
>
> --
> Peter Ehlers
> Department of Mathematics and Statistics
> University of Calgary, 2500 University Dr. NW ph: 403-220-3936
> Calgary, Alberta T2N 1N4, CANADA fax: 403-282-5150
>
>
>
-------------------------------------------------
WebMail Bignet - O seu provedor do litoral
www.bignet.com.br
More information about the R-help
mailing list