[R] stepwise regression

Jinsong Zhao jszhao at mail.hzau.edu.cn
Fri Apr 28 02:58:00 CEST 2006


Dear all,

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

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




More information about the R-help mailing list