[R] stepwise regression

Frank E Harrell Jr f.harrell at vanderbilt.edu
Fri Apr 28 14:09:55 CEST 2006


Jinsong Zhao wrote:
> Dear all,
> 
> I have encountered a problem when perform stepwise regression. 

You have more problems than you know.

> The dataset have more 9 independent variables, but 7 observation.

Why collect any data?  You can get great fits using random numbers using
this procedure.

Frank

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


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                     Department of Biostatistics   Vanderbilt University




More information about the R-help mailing list