Learn R Programming

lsplsGlm (version 1.0)

pls: Weighted PLS gaussian regression

Description

Performs a weighted Partial Least Square gaussian regression.

Usage

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.

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.

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.

Examples

Run this code
# NOT RUN {
#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

# }

Run the code above in your browser using DataLab