2

Note that the previous question flagged as a possible duplicate is not a duplicate because the previous question concerns backwards elimination and this question concerns forward entry.

I am currently performing a simulation where I want to show how stepwise regression is a biased estimator. In particular, previous researchers seem to have used one of the stepwise procedure in SPSS (or something identical to it). This involves using the p-value of the F value for r-square change to determine whether an additional variable should be added into the model. Thus, in order for my simulation results to have the most impact I need to replicate the SPSS stepwise regression procedure in R. While R has a number of stepwise procedures (e.g., based on AIC), the ones that I have found are not the same as SPSS.

I have found this function by Paul Rubin. It seems to work, but the input and output of the function is a little strange. I've started tweaking it so that it (a) take a formula as input, (b) returns the best fitting model. The logic of the function is what I'm after.

I have also found this question on backwards stepwise regression. Note that backwards entry is different to forwards entry because backwards entry removes non-significant terms whereas forwards entry adds significant terms.

Nonetheless, it would be great if there was another function in an existing R package that could do what I want.

Is there an R function designed to perform forward entry stepwise regression using p-values of the F change?

Ideally, it could take a DV a set of IVs (either as named variables or as a formula) and a data.frame and would return the model that the stepwise regression selects as "best". For my purposes, there are no issues with inclusion of interaction terms.

Community
  • 1
  • 1
Jeromy Anglim
  • 33,939
  • 30
  • 115
  • 173
  • @Joris Meys wrote [a function](http://stackoverflow.com/a/3701896/1412059) for this. – Roland May 12 '13 at 14:07
  • 1
    @Dwin I thought all those examples were backwards elimination and not forward entry? I.e., non significant terms are removed rather than significant terms are added; Correct me if I'm wrong. – Jeromy Anglim May 12 '13 at 23:54
  • @Roland I think that function is for backwards elimination not forward entry. This question is asking about forward entry. – Jeromy Anglim May 12 '13 at 23:54

1 Answers1

1

The function two.ways.stepfor in the bioconductor package maSigPro contains a form of forward entry stepwise regression based on p-values.

However, the alpha in and alpha out can be specified and they must be the same. In SPSS the alpha in and alpha out can be different.

The package can be installed with:

source("http://bioconductor.org/biocLite.R")
biocLite("maSigPro")
Jeromy Anglim
  • 33,939
  • 30
  • 115
  • 173