n <- 50 ; p <- 8
Xtrain <- matrix(rnorm(n * p), ncol = p)
colnames(Xtrain) <- paste0("V",1:p)
ytrain <- sample(c(1, 4, 10), size = n, replace = TRUE)
Xtest <- Xtrain[1:5, ] ; ytest <- ytrain[1:5]
Xtrainlist <- list(Xtrain[,1:3], Xtrain[,4:8])
Xtestlist <- list(Xtest[,1:3], Xtest[,4:8])
nlv <- 5
resnlvtestsoplsrda <- soplsr_soplsda_allsteps(Xlist = Xtrainlist,
Xnames = NULL, Xscaling = c("none","pareto","sd")[1],
Y = ytrain, Yscaling = "none", weights = NULL,
newXlist = Xtestlist, newXnames = NULL,
method = c("soplsr", "soplsrda","soplslda","soplsqda")[2],
prior = c("unif", "prop")[1],
step = c("nlvtest","permutation","model","prediction")[1],
nlvlist = list(1:2, 1:2),
modeloutput = c("scores","loadings","coef","vip"),
cvmethod = c("kfolds","loo")[2],
nbrep = 1,
seed = 123,
samplingk = NULL,
nfolds = 10,
npermut = 5,
optimisation = "global",
criterion = c("err","rmse")[1],
selection = c("localmin","globalmin","1std")[1],
outputfilename = NULL)
respermutationsoplsrda <- soplsr_soplsda_allsteps(Xlist = Xtrainlist,
Xnames = NULL, Xscaling = c("none","pareto","sd")[1],
Y = ytrain, Yscaling = "none", weights = NULL,
newXlist = Xtestlist, newXnames = NULL,
method = c("soplsr", "soplsrda","soplslda","soplsqda")[2],
prior = c("unif", "prop")[1],
step = c("nlvtest","permutation","model","prediction")[2],
nlv = c(2,1),
modeloutput = c("scores","loadings","coef","vip"),
cvmethod = c("kfolds","loo")[2],
nbrep = 1,
seed = 123,
samplingk = NULL,
nfolds = 10,
npermut = 5,
criterion = c("err","rmse")[1],
selection = c("localmin","globalmin","1std")[1],
outputfilename = NULL)
plotxy(respermutationsoplsrda, pch=16)
abline (h = respermutationsoplsrda[respermutationsoplsrda[,"permut_dyssimilarity"]==0,"res_permut"])
resmodelsoplsrda <- soplsr_soplsda_allsteps(Xlist = Xtrainlist,
Xnames = NULL, Xscaling = c("none","pareto","sd")[1],
Y = ytrain, Yscaling = "none", weights = NULL,
newXlist = Xtestlist, newXnames = NULL,
method = c("soplsr", "soplsrda","soplslda","soplsqda")[2],
prior = c("unif", "prop")[1],
step = c("nlvtest","permutation","model","prediction")[3],
nlv = c(2,1),
modeloutput = c("scores","loadings","coef","vip"),
cvmethod = c("kfolds","loo")[2],
nbrep = 1,
seed = 123,
samplingk = NULL,
nfolds = 10,
npermut = 5,
criterion = c("err","rmse")[1],
selection = c("localmin","globalmin","1std")[1],
outputfilename = NULL)
resmodelsoplsrda$scores
resmodelsoplsrda$loadings
resmodelsoplsrda$coef
resmodelsoplsrda$vip
respredictionsoplsrda <- soplsr_soplsda_allsteps(Xlist = Xtrainlist,
Xnames = NULL, Xscaling = c("none","pareto","sd")[1],
Y = ytrain, Yscaling = "none", weights = NULL,
newXlist = Xtestlist, newXnames = NULL,
method = c("soplsr", "soplsrda","soplslda","soplsqda")[2],
prior = c("unif", "prop")[1],
step = c("nlvtest","permutation","model","prediction")[4],
nlv = c(2,1),
modeloutput = c("scores","loadings","coef","vip"),
cvmethod = c("kfolds","loo")[2],
nbrep = 1,
seed = 123,
samplingk = NULL,
nfolds = 10,
npermut = 5,
criterion = c("err","rmse")[1],
selection = c("localmin","globalmin","1std")[1],
outputfilename = NULL)
Run the code above in your browser using DataLab