# 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)
#for univariate regression
y <- c("Y1")
notX <- c("Y3")
#for multivariate regression you can use this
ym <- c("Y1","Y3")
notXm <- NULL
#* with continuous variable nested in class effect
ClassY2 <- c("Y2")
#* without continuous variable nested in class effect
Class0 <- NULL
# without forced effect in regression model
inc0 <- NULL
# force the 'Y2' into the regression model
incY2 <- c("Y2")
sele <- 'stepwise'
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, notX, inc0, Class0, w0, sele, "SBC", sle, sls, tol, Trace, 'AIC')
stepwise(yx, y, notX, inc0, Class0, w0, sele, "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, notX, incY2, ClassY2, w2, sele, 'AICc', sle, sls, tol, Trace, 'HQc')
stepwise(yx, y, notX, incY2, ClassY2, w2, sele, '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, ym, notXm, incY2, ClassY2, w2, sele, 'HQ', sle, sls, tol, Trace, 'BIC')
# }
Run the code above in your browser using DataLab