On Thu, 27 Sep 2007, Hans Ole Ørka wrote:

I try to reproduce the SAS proc reg stepwise model selection procedure in R,

But why? If you want 1950s statistical methods why not use a 1960s package? There are enough problems with stepwise selection (see e.g. the book by Frank Harrell and many postings here) even with a well-defined criterion like AIC, but that is better than an ad hoc algorithm, especially one based on forwards selection.
For a flavour of Frank's views see

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/49353.html

Note that step() is stepwise by terms, not by variables. If you have all terms as single variables, package 'leaps' will provide a better algorithm for choosing best subsets. And in that case, step() is essentially the same as using F tests with 'F to enter/leave' = 2 (and you can use different 'k' to get different F limits).

If after further research you still want to do this in R, then R is a fully fledged programming language and it is quite easy to modify step() to use F tests, especially for single-variable terms.

but the only function I found was "step" which select new variables based on AIC. The SAS procedure I use add a new variable to the model based on F statistics and a pre defined significant level. Then before any new variables are added variables in the model that not meet F statistics at the significant level will be removed. I have added the SAS syntax for those of familiar with both software packages.

So I gather 'the significant level' for dropping is in fact not 'the' one used for adding? This is essentially forwards selection.


SAS syntax:
proc reg
       model Y=x1 x2 x3 .....xn
       /selection=stepwise slentry=0.50 slstay=0.05;

All ideas are appreciated
Thanks,
Hans Ole Ørka

--
Brian D. Ripley,                  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595
______________________________________________
[email protected] 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.

Reply via email to