plsR {plsRglm} | R Documentation |
Partial least squares Regression models with leave one out cross validation
Description
This function implements Partial least squares Regression models with leave one out cross validation for complete or incomplete datasets.
Usage
plsR(object, ...)
## Default S3 method:
plsRmodel(object, dataX, nt = 2, limQ2set = 0.0975,
dataPredictY = dataX, modele = "pls", family = NULL, typeVC = "none",
EstimXNA = FALSE, scaleX = TRUE, scaleY = NULL, pvals.expli = FALSE,
alpha.pvals.expli = 0.05, MClassed = FALSE, tol_Xi = 10^(-12), weights,
sparse = FALSE, sparseStop = TRUE, naive = FALSE,verbose=TRUE,...)
## S3 method for class 'formula'
plsRmodel(object, data, nt = 2, limQ2set = 0.0975,
dataPredictY, modele = "pls", family = NULL, typeVC = "none",
EstimXNA = FALSE, scaleX = TRUE, scaleY = NULL, pvals.expli = FALSE,
alpha.pvals.expli = 0.05, MClassed = FALSE, tol_Xi = 10^(-12), weights,
subset, contrasts = NULL, sparse = FALSE, sparseStop = TRUE, naive = FALSE,
verbose=TRUE,...)
PLS_lm(dataY, dataX, nt = 2, limQ2set = 0.0975, dataPredictY = dataX,
modele = "pls", family = NULL, typeVC = "none", EstimXNA = FALSE,
scaleX = TRUE, scaleY = NULL, pvals.expli = FALSE,
alpha.pvals.expli = 0.05, MClassed = FALSE, tol_Xi = 10^(-12),
weights,sparse=FALSE,sparseStop=FALSE,naive=FALSE,verbose=TRUE)
PLS_lm_formula(formula,data=NULL,nt=2,limQ2set=.0975,dataPredictY=dataX,
modele="pls",family=NULL,typeVC="none",EstimXNA=FALSE,scaleX=TRUE,
scaleY=NULL,pvals.expli=FALSE,alpha.pvals.expli=.05,MClassed=FALSE,
tol_Xi=10^(-12),weights,subset,contrasts=NULL,sparse=FALSE,
sparseStop=FALSE,naive=FALSE,verbose=TRUE)
Arguments
object |
response (training) dataset or an object of class " |
dataY |
response (training) dataset |
dataX |
predictor(s) (training) dataset |
formula |
an object of class " |
data |
an optional data frame, list or environment (or object coercible by |
nt |
number of components to be extracted |
limQ2set |
limit value for the Q2 |
dataPredictY |
predictor(s) (testing) dataset |
modele |
name of the PLS model to be fitted, only ( |
family |
for the present moment the family argument is ignored and set thanks to the value of modele. |
typeVC |
type of leave one out cross validation. Several procedures are available. If cross validation is required, one needs to selects the way of predicting the response for left out observations. For complete rows, without any missing value, there are two different ways of computing these predictions. As a consequence, for mixed datasets, with complete and incomplete rows, there are two ways of computing prediction : either predicts any row as if there were missing values in it (
|
EstimXNA |
only for |
scaleX |
scale the predictor(s) : must be set to TRUE for |
scaleY |
scale the response : Yes/No. Ignored since non always possible for glm responses. |
pvals.expli |
should individual p-values be reported to tune model selection ? |
alpha.pvals.expli |
level of significance for predictors when pvals.expli=TRUE |
MClassed |
number of missclassified cases, should only be used for binary responses |
tol_Xi |
minimal value for Norm2(Xi) and |
weights |
an optional vector of 'prior weights' to be used in the fitting process. Should be |
subset |
an optional vector specifying a subset of observations to be used in the fitting process. |
contrasts |
an optional list. See the |
sparse |
should the coefficients of non-significant predictors (< |
sparseStop |
should component extraction stop when no significant predictors (< |
naive |
Use the naive estimates for the Degrees of Freedom in plsR? Default is |
verbose |
should info messages be displayed ? |
... |
arguments to pass to |
Details
There are several ways to deal with missing values that leads to different computations of leave one out cross validation criteria.
A typical predictor has the form response ~ terms where response is the (numeric) response vector and terms is a series of terms which specifies a linear predictor for response. A terms specification of the form first + second indicates all the terms in first together with all the terms in second with any duplicates removed.
A specification of the form first:second indicates the the set of terms obtained by taking the interactions of all terms in first with all terms in second. The specification first*second indicates the cross of first and second. This is the same as first + second + first:second.
The terms in the formula will be re-ordered so that main effects come first, followed by the interactions, all second-order, all third-order and so on: to avoid this pass a terms object as the formula.
Non-NULL weights can be used to indicate that different observations have different dispersions (with the values in weights being inversely proportional to the dispersions); or equivalently, when the elements of weights are positive integers w_i, that each response y_i is the mean of w_i unit-weight observations.
The default estimator for Degrees of Freedom is the Kramer and Sugiyama's one. Information criteria are computed accordingly to these estimations. Naive Degrees of Freedom and Information Criteria are also provided for comparison purposes. For more details, see N. Kraemer and M. Sugiyama. (2011). The Degrees of Freedom of Partial Least Squares Regression. Journal of the American Statistical Association, 106(494), 697-705, 2011.
Value
nr |
Number of observations |
nc |
Number of predictors |
nt |
Number of requested components |
ww |
raw weights (before L2-normalization) |
wwnorm |
L2 normed weights (to be used with deflated matrices of predictor variables) |
wwetoile |
modified weights (to be used with original matrix of predictor variables) |
tt |
PLS components |
pp |
loadings of the predictor variables |
CoeffC |
coefficients of the PLS components |
uscores |
scores of the response variable |
YChapeau |
predicted response values for the dataX set |
residYChapeau |
residuals of the deflated response on the standardized scale |
RepY |
scaled response vector |
na.miss.Y |
is there any NA value in the response vector |
YNA |
indicatrix vector of missing values in RepY |
residY |
deflated scaled response vector |
ExpliX |
scaled matrix of predictors |
na.miss.X |
is there any NA value in the predictor matrix |
XXNA |
indicator of non-NA values in the predictor matrix |
residXX |
deflated predictor matrix |
PredictY |
response values with NA replaced with 0 |
press.ind |
individual PRESS value for each observation (scaled scale) |
press.tot |
total PRESS value for all observations (scaled scale) |
family |
glm family used to fit PLSGLR model |
ttPredictY |
PLS components for the dataset on which prediction was requested |
typeVC |
type of leave one out cross-validation used |
dataX |
predictor values |
dataY |
response values |
computed_nt |
number of components that were computed |
CoeffCFull |
matrix of the coefficients of the predictors |
CoeffConstante |
value of the intercept (scaled scale) |
Std.Coeffs |
Vector of standardized regression coefficients |
press.ind2 |
individual PRESS value for each observation (original scale) |
RSSresidY |
residual sum of squares (scaled scale) |
Coeffs |
Vector of regression coefficients (used with the original data scale) |
Yresidus |
residuals of the PLS model |
RSS |
residual sum of squares (original scale) |
residusY |
residuals of the deflated response on the standardized scale |
AIC.std |
AIC.std vs number of components (AIC computed for the standardized model |
AIC |
AIC vs number of components |
optional |
If the response is assumed to be binary:
|
ttPredictFittedMissingY |
Description of 'comp2' |
optional |
If cross validation was requested:
|
InfCrit |
table of Information Criteria |
Std.ValsPredictY |
predicted response values for supplementary dataset (standardized scale) |
ValsPredictY |
predicted response values for supplementary dataset (original scale) |
Std.XChapeau |
estimated values for missing values in the predictor matrix (standardized scale) |
XXwotNA |
predictor matrix with missing values replaced with 0 |
Note
Use cv.plsR
to cross-validate the plsRglm models and bootpls
to bootstrap them.
Author(s)
Frederic Bertrand
frederic.bertrand@utt.fr
https://fbertran.github.io/homepage/
References
Nicolas Meyer, Myriam Maumy-Bertrand et Frederic Bertrand (2010). Comparing the linear and the logistic PLS regression with qualitative predictors: application to allelotyping data. Journal de la Societe Francaise de Statistique, 151(2), pages 1-18. http://publications-sfds.math.cnrs.fr/index.php/J-SFdS/article/view/47
See Also
See also plsRglm
to fit PLSGLR models.
Examples
data(Cornell)
XCornell<-Cornell[,1:7]
yCornell<-Cornell[,8]
#maximum 6 components could be extracted from this dataset
#trying 10 to trigger automatic stopping criterion
modpls10<-plsR(yCornell,XCornell,10)
modpls10
#With iterated leave one out CV PRESS
modpls6cv<-plsR(Y~.,data=Cornell,6,typeVC="standard")
modpls6cv
cv.modpls<-cv.plsR(Y~.,data=Cornell,6,NK=100, verbose=FALSE)
res.cv.modpls<-cvtable(summary(cv.modpls))
plot(res.cv.modpls)
rm(list=c("XCornell","yCornell","modpls10","modpls6cv"))
#A binary response example
data(aze_compl)
Xaze_compl<-aze_compl[,2:34]
yaze_compl<-aze_compl$y
modpls.aze <- plsR(yaze_compl,Xaze_compl,10,MClassed=TRUE,typeVC="standard")
modpls.aze
#Direct access to not cross-validated values
modpls.aze$AIC
modpls.aze$AIC.std
modpls.aze$MissClassed
#Raw predicted values (not really probabily since not constrained in [0,1]
modpls.aze$Probs
#Truncated to [0;1] predicted values (true probabilities)
modpls.aze$Probs.trc
modpls.aze$Probs-modpls.aze$Probs.trc
#Repeated cross validation of the model (NK=100 times)
cv.modpls.aze<-cv.plsR(y~.,data=aze_compl,10,NK=100, verbose=FALSE)
res.cv.modpls.aze<-cvtable(summary(cv.modpls.aze,MClassed=TRUE))
#High discrepancy in the number of component choice using repeated cross validation
#and missclassed criterion
plot(res.cv.modpls.aze)
rm(list=c("Xaze_compl","yaze_compl","modpls.aze","cv.modpls.aze","res.cv.modpls.aze"))
#24 predictors
dimX <- 24
#2 components
Astar <- 2
simul_data_UniYX(dimX,Astar)
dataAstar2 <- data.frame(t(replicate(250,simul_data_UniYX(dimX,Astar))))
modpls.A2<- plsR(Y~.,data=dataAstar2,10,typeVC="standard")
modpls.A2
cv.modpls.A2<-cv.plsR(Y~.,data=dataAstar2,10,NK=100, verbose=FALSE)
res.cv.modpls.A2<-cvtable(summary(cv.modpls.A2,verbose=FALSE))
#Perfect choice for the Q2 criterion in PLSR
plot(res.cv.modpls.A2)
#Binarized data.frame
simbin1 <- data.frame(dicho(dataAstar2))
modpls.B2 <- plsR(Y~.,data=simbin1,10,typeVC="standard",MClassed=TRUE, verbose=FALSE)
modpls.B2
modpls.B2$Probs
modpls.B2$Probs.trc
modpls.B2$MissClassed
plsR(simbin1$Y,dataAstar2[,-1],10,typeVC="standard",MClassed=TRUE,verbose=FALSE)$InfCrit
cv.modpls.B2<-cv.plsR(Y~.,data=simbin1,2,NK=100,verbose=FALSE)
res.cv.modpls.B2<-cvtable(summary(cv.modpls.B2,MClassed=TRUE))
#Only one component found by repeated CV missclassed criterion
plot(res.cv.modpls.B2)
rm(list=c("dimX","Astar","dataAstar2","modpls.A2","cv.modpls.A2",
"res.cv.modpls.A2","simbin1","modpls.B2","cv.modpls.B2","res.cv.modpls.B2"))