pls: Weighted PLS gaussian regression

Description Usage Arguments Details Value Author(s) Examples

View source: R/pls.R

Description

Performs a weighted Partial Least Square gaussian regression.

Usage

1
pls(Y,X,W = diag(rep(1, length(Y))),ncomp)

Arguments

Y

a vector of length n giving the classes of the n observations. Y contains continuous values.

X

a data matrix (nxp) of genes. NAs and Inf are not allowed. Each row corresponds to an observation and each column to a gene.

W

weight matrix, if W is the identity matrix then the function will perform a standard PLS regression.

ncomp

a positive integer. ncomp is the number of PLS components.

Details

This function performs a weighted PLS gaussian regression. It takes as input a vector of response, a data matrix about genes, a number of component and a weight matrix. If weight matrix is the identity matrix then it performs a standard PLS regression.

Value

coefficients

an array of regression coefficients ((p+1)xncomp).

projection

the projection matrix, used to convert X to scores.

scores

the scores matrix (nxncomp) of PLS regression.

intercept

the constant of the model.

Author(s)

Caroline Bazzoli, Thomas Bouleau, Sophie Lambert-Lacroix

Examples

 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
#X simulation
meanX<-sample(1:300,50)
sdeX<-sample(50:150,50)
X<-matrix(nrow=60,ncol=50)
for (i in 1:50){
  X[,i]<-rnorm(60,meanX[i],sdeX[i])
}

#Y simulation
Y<-rnorm(60,30,10)

# Learning sample
index<-sample(1:length(Y),round(2*length(Y)/3))
XL<-X[index,]
YL<-Y[index]

#fit the model
fit<-pls(Y=YL,X=XL,ncomp=3)

#Testing sample
newX=X[-index,]

#predictions with the constant of the model
a.coefficients<-rbind(fit$intercept,fit$coefficients)

#predictions
newY=cbind(rep(1,dim(newX)[1]),newX)%*%a.coefficients

lsplsGlm documentation built on July 27, 2017, 5:01 p.m.