# NOT RUN {
set.seed(4)
dfY <- data.frame(matrix(c(rnorm(20,0,2),c(rep(1,10),rep(2,10)),rnorm(20,2,3)),20,3))
colnames(dfY) <- paste("Y",1:3,sep="")
dfX <- data.frame(matrix(c(rnorm(100,0,2),rnorm(100,2,1)),20,10))
colnames(dfX) <- paste("X",1:10,sep="")
yx <- cbind(dfY,dfX)
tol <- 1e-7
Trace <- "Pillai"
sle <- 0.15
sls <- 0.15
# weights vector
w0 <- c(rep(0.5,2),rep(1,18))
w2 <- c(rep(0.5,3),rep(1,14),0.5,1,0.5)
#univariate regression with select = 'SBC' & choose = 'AIC' and select = 'CP' & choose = NULL
#without forced effect and continuous variable nested in class effect
stepwise(yx, y="Y1", exclude="Y3", include=NULL, Class=NULL,w0,
selection="backward", select="SBC", sle, sls, tol, Trace, Choose='AIC')
stepwise(yx, y="Y1",exclude="Y3", include=NULL, Class=NULL, w0,
selection="bidirection", select="CP", sle, sls, tol, Trace, NULL)
#univariate regression with select='AICc' & choose='HQc' and select='BIC' & choose = NULL
#with forced effect and continuous variable nested in class effect
stepwise(yx, y="Y1", exclude="Y3", include="Y2", Class="Y2", w2,
selection="forward", select='AICc', sle, sls, tol, Trace, 'HQc')
stepwise(yx, y="Y1", exclude="Y3", include="Y2", Class="Y2", w2,
selection="bidirection", 'BIC', sle, sls, tol, Trace, NULL)
#multivariate regression with select='HQ' & choose='BIC'
#with forced effect and continuous variable nested in class effect
stepwise(yx, y=c("Y1","Y3"), exclude=NULL, include="Y2", Class="Y2", w2,
selection="bidirection", select='HQ', sle, sls, tol, Trace, 'BIC')
# }
Run the code above in your browser using DataLab