[R] problem with mle.stepwise

eariasca eariasca at math.ucsd.edu
Sat May 16 01:18:11 CEST 2009


I am getting some unexpected results when using mle.stepwise:


x1 = runif(100)
x2 = runif(100)
y = 3 + 2*x1 + rnorm(100)	

# so x1 is in the model, but not x2

mle.stepwise(y ~ x1 + x2, type = "Backward")		

# Backward selection gets it right, the other two return non-sense

mle.stepwise(y ~ x1 + x2)	
mle.stepwise(y ~ x1 + x2, type = "Stepwise")

# If the variables are entered in a different order, the result changes

mle.stepwise(y ~ x2 + x1)
mle.stepwise(y ~ x2 + x1, type = "Stepwise")


I am running R version 2.6.0 Patched (2007-11-09 r43408) on Mac OS X  
10.4.11 and the latest version of wle 0.9-3.

Any idea?  Help much appreciated.  I will introduce these functions  
in my applied statistics class on Monday!


More information about the R-help mailing list