Skip to content
Prev 67087 / 398506 Next

step error

an indirect solution is to use the following:

pro <- function(indep, dep){
    d <- data.frame(indep)
    form <- formula(lm(dep~., data=d))
    assign("d", d, envir=.GlobalEnv)
    res <- step(lm(dep~X1, data=d), scope=form, trace=0, 
direction="f")
    rm("d", envir=.GlobalEnv)
    res
}
#########
m <- rnorm(100*5); dim(m) <- c(100, 5); colnames(m) <- paste("X", 1:5, 
sep="")
Y <- as.vector(1 + m[, sample(5, 2)]%*%rnorm(2))
pro(m, Y)
step(lm(Y~X1, data=data.frame(m)), scope=Y~X1+X2+X3+X4+X5, trace=0, 
direction="f")

I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "vasilis pappas" <vasileios_p at yahoo.gr>
To: <r-help at stat.math.ethz.ch>
Sent: Friday, April 01, 2005 9:29 PM
Subject: [R] step error