An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111104/cc7b90d6/attachment.pl>
Select some, but not all, variables stepwise
6 messages · Andre Easom, Francisco Mora Ardila, AndreE +1 more
Resist the temptation. Stepwise analysis without shrinkage will ruin model inferences without helping with predictive accuracy. Frank
AndreE wrote:
Hi,
I would like to fit a linear model where some but not all explanators are
chosen stepwise - ie I definitely want to include some terms, but others
only if they are deemed significant (by AIC or whatever other approach is
available). For example if I wanted to definitely include x1 and x2, but
only include z1 and z2 if they are significant, something like this:
df <- data.frame(y=c(4,2,6,7,3,9,5,7,6,2), x1=c(2,3,4,0,5,8,8,1,1,2),
x2=c(0,0,0,0,1,1,0,0,0,1), z1=c(0,1,0,0,0,1,1,0,1,1),
z2=c(1,1,1,0,0,1,1,1,1,0))
model <- lm(y ~ x1 + x2 + stepwise(z1 + z2))
Any help would be appreciated.
Cheers,
Andre
**********************************************************************
This email and any attachments are confidential, protect...{{dropped:22}}
______________________________________________ R-help@ 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.
----- Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Select-some-but-not-all-variables-stepwise-tp3990002p3990026.html Sent from the R help mailing list archive at Nabble.com.
Hi Andre I don?t know if it will work, but I?ve tried the MuMIn package, were you can evaluate all possible models (usin for example AIC) at one time. Maybe you can focus on comparing those models which retain the explanators you want. Best wishes Francisco On Fri, 4 Nov 2011 13:06:09 +0000, Andre Easom wrote
Hi,
I would like to fit a linear model where some but not all explanators are
chosen stepwise - ie I definitely want to include some terms, but others only
if they are deemed significant (by AIC or whatever other approach is available)
. For example if I wanted to definitely include x1 and x2, but only include
z1 and z2 if they are significant, something like this:
df <- data.frame(y=c(4,2,6,7,3,9,5,7,6,2), x1=c(2,3,4,0,5,8,8,1,1,2), x2=c(0,0,
0,0,1,1,0,0,0,1), z1=c(0,1,0,0,0,1,1,0,1,1), z2=c(1,1,1,0,0,1,1,1,1,0)) model
<- lm(y ~ x1 + x2 + stepwise(z1 + z2))
Any help would be appreciated.
Cheers,
Andre
**********************************************************************
This email and any attachments are confidential, protect...{{dropped:22}}
______________________________________________ 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.
Francisco Mora Ardila Laboratorio de Biodiversidad y Funcionamiento del Ecosistema Centro de Investigaciones en Ecosistemas UNAM-Campus Morelia Tel 3222777 ext. 42621 Morelia , MIchoac?n, M?xico. -- Open WebMail Project (http://openwebmail.org)
Thanks Francisco - I've actually realized that ?step can do pretty much exactly what I want. Andre -- View this message in context: http://r.789695.n4.nabble.com/Select-some-but-not-all-variables-stepwise-tp3990002p3990516.html Sent from the R help mailing list archive at Nabble.com.
Why do any of that? Those procedures are statistically invalid. Frank
AndreE wrote:
Thanks Francisco - I've actually realized that ?step can do pretty much exactly what I want. Andre
----- Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Select-some-but-not-all-variables-stepwise-tp3990002p3990598.html Sent from the R help mailing list archive at Nabble.com.
2 days later
Thanks for the advice - I will consider some alternative strategies. -- View this message in context: http://r.789695.n4.nabble.com/Select-some-but-not-all-variables-stepwise-tp3990002p3998065.html Sent from the R help mailing list archive at Nabble.com.