[R] stepwise regression

Thomas Lumley tlumley at u.washington.edu
Fri Apr 28 16:11:16 CEST 2006


On Fri, 28 Apr 2006, Jinsong Zhao wrote:

> Dear all,
>
> I have encountered a problem when perform stepwise regression.
> The dataset have more 9 independent variables, but 7 observation.
>

The functions in the "leaps" package can do subset selection for data sets 
with more variables than observations.

 	-thomas


> In R, before performing stepwise, a lm object should be given.
> fm <- lm(y ~ X1 + X2 + X3 + X11 + X22 + X33 + X12 + X13 + X23)
>
> However, summary(fm) will give:
>
> Residual standard error: NaN on 0 degrees of freedom
> Multiple R-Squared:     1,      Adjusted R-squared:   NaN
> F-statistic:   NaN on 6 and 0 DF,  p-value: NA
>
> In this situation, step() or stepAIC() will not give any useful information.
>
> I don't know why SAS could deal with this situation:
> PROC REG;
> MODEL y=X1 X2 X3 X11 X22 X33 X12 X13 X23/SELECTION=STEPWISE;
> RUN;
>
> Any help will be really appreciated.
>
> Wishes,
>
> Jinsong Zhao
>
>

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle




More information about the R-help mailing list