Description Usage Arguments Details Value Author(s) References See Also Examples
The function spls.adapt
performs compression, variable selection in regression context
(with possible prediction) using Durif et al. (2015) adaptive SPLS algorithm, based on sparse
PLS developped by Chun and Keles (2010).
1 2 3 
Xtrain 
a (ntrain x p) data matrix of predictors. 
Ytrain 
a (ntrain) vector of (continuous) responses. 
lambda.l1 
a positive real value, in [0,1]. 
ncomp 
a positive integer. 
weight.mat 
a (ntrain x ntrain) matrix used to weight the l2 metric in observation space if necessary, especially the covariance inverse of the Ytrain observations in heteroskedastic context. If NULL, the l2 metric is the standard one, corresponding to homoskedastic model. 
Xtest 
a (ntest x p) matrix containing the predictors for the test data set.

adapt 
a boolean value, indicating whether the sparse PLS selection step sould be adaptive or not. 
center.X 
a boolean value indicating whether the design matrices Xtrain in train set and Xtest in test set if non NULL should be centered or not 
scale.X 
a boolean value indicating whether the design matrices Xtrain in train set and Xtest in test set if non NULL should be scaled or not, scale.X=TRUE implies center.X=TRUE 
center.Y 
a boolean value indicating whether the response Ytrain in train set should be centered or not 
scale.Y 
a boolean value indicating whether the response Ytrain should be scaled or not, scale.Y=TRUE implies center.Y=TRUE 
weighted.center 
a boolean value indicating whether should the centering take into account the weighted l2 metric or not (if TRUE, it implies that weighted.mat is non NULL). 
The columns of the data matrices Xtrain
and Xtest
may not be standardized,
since standardizing is can be performed by the function spls.adapt
as a preliminary
step before the algorithm is run.
The procedure described in Durif et al. (2015) is used to determine
latent sparse components to be used for regression and when Xtest
is not equal to NULL, the procedure predicts the response for these new
predictor variables.
A list with the following components:
Xtrain 
the design matrix. 
Ytrain 
the response observations. 
sXtrain 
the centered if so and scaled if so design matrix. 
sYtrain 
the centered if so and scaled if so response. 
betahat 
the linear coefficients in model

betahat.nc 
the (p+1) vector containing the coefficients and intercept for the non
centered and non scaled model

meanXtrain 
the (p) vector of Xtrain column mean, used for centering if so. 
sigmaXtrain 
the (p) vector of Xtrain column standard deviation, used for scaling if so. 
meanYtrain 
the mean of Ytrain, used for centering if so. 
sigmaYtrain 
the standard deviation of Ytrain, used for centering if so. 
X.score 
a (n x ncomp) matrix being the observations coordinates or scores in the
new component basis produced by the compression step (sparse PLS). Each column t.k of

X.score.low 
a (n x ncomp) matrix being the observations coordinates in the subspace of selected variables. 
X.loading 
the (ncomp x p) matrix of coefficients in regression of Xtrain over the new
components 
Y.loading 
the (ncomp) vector of coefficients in regression of Ytrain over the new
components 
X.weight 
a (p x ncomp) matrix being the coefficients of predictors in each components
produced by sparse PLS. Each column w.k of 
residuals 
the (ntrain) vector of residuals in the model

residuals.nc 
the (ntrain) vector of residuals in the non centered non scaled model

hatY 
the (ntrain) vector containing the estimated reponse value on the train set of
centered and scaled (if so) predictors 
hatY.nc 
the (ntrain) vector containing the estimated reponse value on the train set of
non centered and non scaled predictors 
hatYtest 
the (ntest) vector containing the predicted values for the response on the
centered and scaled test set 
hatYtest.nc 
the (ntest) vector containing the predicted values for the response on the
non centered and non scaled test set 
A 
the active set of predictors selected by the procedures. 
betamat 
a (ncomp) list of coefficient vector betahat in the model with 
new2As 
a (ncomp) list of subset of 
lambda.l1 
the sparse hyperparameter used to fit the model. 
ncomp 
the number of components used to fit the model. 
V 
the (ntrain x ntrain) matrix used to weight the metric in the sparse PLS step. 
adapt 
a boolean value, indicating whether the sparse PLS selection step was adaptive or not. 
Ghislain Durif (http://lbbe.univlyon1.fr/DurifGhislain.html).
Adapted in part from spls code by H. Chun, D. Chung and S.Keles (http://cran.rproject.org/web/packages/spls/index.html).
G. Durif, F. Picard, S. LambertLacroix (2015). Adaptive sparse PLS for logistic regression, (in prep), available on (http://arxiv.org/abs/1502.05933).
Chun, H., & Keles, S. (2010). Sparse partial least squares regression for simultaneous dimension reduction and variable selection. Journal of the Royal Statistical Society. Series B (Methodological), 72(1), 325. doi:10.1111/j.14679868.2009.00723.x
Chung, D., & Keles, S. (2010). Sparse partial least squares classification for high dimensional data. Statistical Applications in Genetics and Molecular Biology, 9, Article17. doi:10.2202/15446115.1492
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45  ### load plsgenomics library
library(plsgenomics)
### generating data
n < 100
p < 1000
sample1 < sample.cont(n=n, p=p, kstar=20, lstar=2, beta.min=0.25, beta.max=0.75,
mean.H=0.2, sigma.H=10, sigma.F=5, sigma.E=5)
X < sample1$X
Y < sample1$Y
### splitting between learning and testing set
index.train < sort(sample(1:n, size=round(0.7*n)))
index.test < (1:n)[index.train]
Xtrain < X[index.train,]
Ytrain < Y[index.train,]
Xtest < X[index.test,]
Ytest < Y[index.test,]
### fitting the model, and predicting new observations
model1 < spls.adapt(Xtrain=Xtrain, Ytrain=Ytrain, lambda.l1=0.5, ncomp=2, weight.mat=NULL,
Xtest=Xtest, adapt=TRUE, center.X=TRUE, center.Y=TRUE, scale.X=TRUE,
scale.Y=TRUE, weighted.center=FALSE)
str(model1)
### plotting the estimation versus real values for the non centered response
plot(model1$Ytrain, model1$hatY.nc, xlab="real Ytrain", ylab="Ytrain estimates")
points(1000:1000,1000:1000, type="l")
### plotting residuals versus centered response values
plot(model1$sYtrain, model1$residuals, xlab="sYtrain", ylab="residuals")
### plotting the predictor coefficients
plot(model1$betahat.nc, xlab="variable index", ylab="coeff")
### mean squares error of prediction on test sample
sYtest < as.matrix(scale(Ytest, center=model1$meanYtrain, scale=model1$sigmaYtrain))
sum((model1$hatYtest  sYtest)^2) / length(index.test)
### plotting predicted values versus non centered real response values on the test set
plot(model1$hatYtest, sYtest, xlab="real Ytest", ylab="predicted values")
points(1000:1000,1000:1000, type="l")

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.