Learn R Programming

lsplsGlm (version 1.0)

fit.lspcr.glm: Fitting a LS-PCR model for logistic regression

Description

Fits a model the combination of two methods: Ordinary Least Square (OLS) and Principal Component Regression (PCR) to fit both clinical and gene expression data.

Usage

fit.lspcr.glm(Y,X,D,ncomp)

Arguments

Y

a vector of length n giving the classes of the n observations. The classes must be coded as 1 or 0.

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.

D

a data matrix (nxq) of clinical data. NAs and Inf are not allowed. Each row corresponds to an observation and each column to a clinical variable.

ncomp

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

Value

coefficients

coefficients of logistic regression.

cvg

the 0-1 value indicating convergence of the algorithm (1 for convergence, 0 otherwise).

projection

projection matrix used to convert X to scores.

Details

This function combines two methods, the first one is the Principal Components Regression on genetic data to reduce the dimension using prcomp from {stats} package. The second one is the logistic regression on the concatenation of the ncomp first selected axes and clinical data (D) to explain Y. To do that we use glm from {stats} package.

See Also

cv.lspcr.glm,predict.lspcr.glm.

Examples

Run this code
# NOT RUN {
#Data
data(BreastCancer)
#Vector of response
Y<-BreastCancer$Y
#Genetic data
X<-BreastCancer$X
#Clinical data
D<-BreastCancer$D
#Apply fit.lspcr.glm with ncomp=5 using the 76 first patients
fit<-fit.lspcr.glm(Y=Y[1:76],X=X[1:76,],D=D[1:76,],ncomp=5)

#using projection to predict class of 2 last patients
newX<-X[77:78,]
newD<-D[77:78,]

#New Score matrix
newScores<-newX%*%fit$projection

#prediction
newEta=cbind(rep(1,dim(newD)[1]),newD,newScores)%*%fit$coefficients
newPi=1/(1+exp(-newEta))
newY=as.numeric(newEta>0)
# }

Run the code above in your browser using DataLab