plsRglm | R Documentation |
This function implements Partial least squares Regression generalized linear models complete or incomplete datasets.
plsRglm(object, ...)
## Default S3 method:
plsRglmmodel(object,dataX,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,
sparse=FALSE,sparseStop=TRUE,naive=FALSE,verbose=TRUE,...)
## S3 method for class 'formula'
plsRglmmodel(object,data=NULL,nt=2,limQ2set=.0975,
dataPredictY,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,
start=NULL,etastart,mustart,offset,method="glm.fit",control= list(),
contrasts=NULL,sparse=FALSE,sparseStop=TRUE,naive=FALSE,verbose=TRUE,...)
PLS_glm(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,
method, sparse = FALSE, sparseStop=FALSE, naive=FALSE,verbose=TRUE)
PLS_glm_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,start=NULL,etastart,mustart,offset,method,
control= list(),contrasts=NULL,sparse=FALSE,sparseStop=FALSE,naive=FALSE,verbose=TRUE)
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 glm model to be fitted ( |
family |
a description of the error distribution and link function to be used in the model. This can be a character string naming a family function, a family function or the result of a call to a family function. (See |
typeVC |
type of leave one out cross validation. For back compatibility purpose.
|
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. |
start |
starting values for the parameters in the linear predictor. |
etastart |
starting values for the linear predictor. |
mustart |
starting values for the vector of means. |
offset |
this can be used to specify an a priori known component to be included in the linear predictor during fitting. This should be |
method |
For a glm model ( |
control |
a list of parameters for controlling the fitting process. For |
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 details be displayed ? |
... |
arguments to pass to |
There are seven different predefined models with predefined link functions available :
"pls"
ordinary pls models
"pls-glm-Gamma"
glm gaussian with inverse link pls models
"pls-glm-gaussian"
glm gaussian with identity link pls models
"pls-glm-inverse-gamma"
glm binomial with square inverse link pls models
"pls-glm-logistic"
glm binomial with logit link pls models
"pls-glm-poisson"
glm poisson with log link pls models
"pls-glm-polr"
glm polr with logit link pls models
Using the "family="
option and setting "modele=pls-glm-family"
allows changing the family and link function the same way as for the glm
function. As a consequence user-specified families can also be used.
gaussian
familyaccepts the links (as names) identity
, log
and inverse
.
binomial
familyaccepts the links logit
, probit
, cauchit
, (corresponding to logistic, normal and Cauchy CDFs respectively) log
and cloglog
(complementary log-log).
Gamma
familyaccepts the links inverse
, identity
and log
.
poisson
familyaccepts the links log
, identity
, and sqrt
.
inverse.gaussian
familyaccepts the links 1/mu^2
, inverse
, identity
and log
.
quasi
familyaccepts the links logit
, probit
, cloglog
, identity
, inverse
, log
, 1/mu^2
and sqrt
.
power
can be used to create a power link function.
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 which only works for classical plsR models. For these models, 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.
Depends on the model that was used to fit the model. You can generally at least find these items.
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 |
RSS |
residual sum of squares (original scale) |
RSSresidY |
residual sum of squares (scaled scale) |
R2residY |
R2 coefficient value on the standardized scale |
R2 |
R2 coefficient value on the original scale |
press.ind |
individual PRESS value for each observation (scaled scale) |
press.tot |
total PRESS value for all observations (scaled scale) |
Q2cum |
cumulated Q2 (standardized 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 |
weights |
weights of the observations |
computed_nt |
number of components that were computed |
AIC |
AIC vs number of components |
BIC |
BIC vs number of components |
Coeffsmodel_vals |
|
ChisqPearson |
|
CoeffCFull |
matrix of the coefficients of the predictors |
CoeffConstante |
value of the intercept (scaled scale) |
Std.Coeffs |
Vector of standardized regression coefficients |
Coeffs |
Vector of regression coefficients (used with the original data scale) |
Yresidus |
residuals of the PLS model |
residusY |
residuals of the deflated response on the standardized scale |
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) |
FinalModel |
final GLR model on the PLS components |
XXwotNA |
predictor matrix with missing values replaced with 0 |
call |
call |
AIC.std |
AIC.std vs number of components (AIC computed for the standardized model |
Use cv.plsRglm
to cross-validate the plsRglm models and bootplsglm
to bootstrap them.
Frederic Bertrand
frederic.bertrand@utt.fr
https://fbertran.github.io/homepage/
Nicolas Meyer, Myriam Maumy-Bertrand et Frederic Bertrand (2010). Comparaison de la regression PLS et de la regression logistique PLS : application aux donnees d'allelotypage. 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 plsR
.
data(Cornell)
XCornell<-Cornell[,1:7]
yCornell<-Cornell[,8]
modplsglm <- plsRglm(yCornell,XCornell,10,modele="pls-glm-gaussian")
#To retrieve the final GLR model on the PLS components
finalmod <- modplsglm$FinalModel
#It is a glm object.
plot(finalmod)
#Cross validation
cv.modplsglm<-cv.plsRglm(Y~.,data=Cornell,6,NK=100,modele="pls-glm-gaussian", verbose=FALSE)
res.cv.modplsglm<-cvtable(summary(cv.modplsglm))
plot(res.cv.modplsglm)
#If no model specified, classic PLSR model
modpls <- plsRglm(Y~.,data=Cornell,6)
modpls
modpls$tt
modpls$uscores
modpls$pp
modpls$Coeffs
#rm(list=c("XCornell","yCornell",modpls,cv.modplsglm,res.cv.modplsglm))
data(aze_compl)
Xaze_compl<-aze_compl[,2:34]
yaze_compl<-aze_compl$y
plsRglm(yaze_compl,Xaze_compl,nt=10,modele="pls",MClassed=TRUE, verbose=FALSE)$InfCrit
modpls <- plsRglm(yaze_compl,Xaze_compl,nt=10,modele="pls-glm-logistic",
MClassed=TRUE,pvals.expli=TRUE, verbose=FALSE)
modpls
colSums(modpls$pvalstep)
modpls$Coeffsmodel_vals
plot(plsRglm(yaze_compl,Xaze_compl,4,modele="pls-glm-logistic")$FinalModel)
plsRglm(yaze_compl[-c(99,72)],Xaze_compl[-c(99,72),],4,
modele="pls-glm-logistic",pvals.expli=TRUE)$pvalstep
plot(plsRglm(yaze_compl[-c(99,72)],Xaze_compl[-c(99,72),],4,
modele="pls-glm-logistic",pvals.expli=TRUE)$FinalModel)
rm(list=c("Xaze_compl","yaze_compl","modpls"))
data(bordeaux)
Xbordeaux<-bordeaux[,1:4]
ybordeaux<-factor(bordeaux$Quality,ordered=TRUE)
modpls <- plsRglm(ybordeaux,Xbordeaux,10,modele="pls-glm-polr",pvals.expli=TRUE)
modpls
colSums(modpls$pvalstep)
XbordeauxNA<-Xbordeaux
XbordeauxNA[1,1] <- NA
modplsNA <- plsRglm(ybordeaux,XbordeauxNA,10,modele="pls-glm-polr",pvals.expli=TRUE)
modpls
colSums(modpls$pvalstep)
rm(list=c("Xbordeaux","XbordeauxNA","ybordeaux","modplsNA"))
data(pine)
Xpine<-pine[,1:10]
ypine<-pine[,11]
modpls1 <- plsRglm(ypine,Xpine,1)
modpls1$Std.Coeffs
modpls1$Coeffs
modpls4 <- plsRglm(ypine,Xpine,4)
modpls4$Std.Coeffs
modpls4$Coeffs
modpls4$PredictY[1,]
plsRglm(ypine,Xpine,4,dataPredictY=Xpine[1,])$PredictY[1,]
XpineNAX21 <- Xpine
XpineNAX21[1,2] <- NA
modpls4NA <- plsRglm(ypine,XpineNAX21,4)
modpls4NA$Std.Coeffs
modpls4NA$YChapeau[1,]
modpls4$YChapeau[1,]
modpls4NA$CoeffC
plsRglm(ypine,XpineNAX21,4,EstimXNA=TRUE)$XChapeau
plsRglm(ypine,XpineNAX21,4,EstimXNA=TRUE)$XChapeauNA
# compare pls-glm-gaussian with classic plsR
modplsglm4 <- plsRglm(ypine,Xpine,4,modele="pls-glm-gaussian")
cbind(modpls4$Std.Coeffs,modplsglm4$Std.Coeffs)
# without missing data
cbind(ypine,modpls4$ValsPredictY,modplsglm4$ValsPredictY)
# with missing data
modplsglm4NA <- plsRglm(ypine,XpineNAX21,4,modele="pls-glm-gaussian")
cbind((ypine),modpls4NA$ValsPredictY,modplsglm4NA$ValsPredictY)
rm(list=c("Xpine","ypine","modpls4","modpls4NA","modplsglm4","modplsglm4NA"))
data(fowlkes)
Xfowlkes <- fowlkes[,2:13]
yfowlkes <- fowlkes[,1]
modpls <- plsRglm(yfowlkes,Xfowlkes,4,modele="pls-glm-logistic",pvals.expli=TRUE)
modpls
colSums(modpls$pvalstep)
rm(list=c("Xfowlkes","yfowlkes","modpls"))
if(require(chemometrics)){
data(hyptis)
yhyptis <- factor(hyptis$Group,ordered=TRUE)
Xhyptis <- as.data.frame(hyptis[,c(1:6)])
options(contrasts = c("contr.treatment", "contr.poly"))
modpls2 <- plsRglm(yhyptis,Xhyptis,6,modele="pls-glm-polr")
modpls2$Coeffsmodel_vals
modpls2$InfCrit
modpls2$Coeffs
modpls2$Std.Coeffs
table(yhyptis,predict(modpls2$FinalModel,type="class"))
rm(list=c("yhyptis","Xhyptis","modpls2"))
}
dimX <- 24
Astar <- 6
dataAstar6 <- t(replicate(250,simul_data_UniYX(dimX,Astar)))
ysimbin1 <- dicho(dataAstar6)[,1]
Xsimbin1 <- dicho(dataAstar6)[,2:(dimX+1)]
modplsglm <- plsRglm(ysimbin1,Xsimbin1,10,modele="pls-glm-logistic")
modplsglm
simbin=data.frame(dicho(dataAstar6))
cv.modplsglm <- suppressWarnings(cv.plsRglm(Y~.,data=simbin,nt=10,
modele="pls-glm-logistic",NK=100, verbose=FALSE))
res.cv.modplsglm <- cvtable(summary(cv.modplsglm,MClassed=TRUE,
verbose=FALSE))
plot(res.cv.modplsglm) #defaults to type="CVMC"
rm(list=c("dimX","Astar","dataAstar6","ysimbin1","Xsimbin1","modplsglm","cv.modplsglm",
"res.cv.modplsglm"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.