Learn R Programming

lsplsGlm (version 1.0)

predict.lspcr.glm: Predict method for LS-PCR fits.

Description

Obtains predictions and prediction probabilities from a fitted LS-PCR object.

Usage

# S3 method for lspcr.glm
predict(object,newX,newD,...)

Arguments

object

results from fit.lspcr.glm function.

newX

new matrix of genetic data.

newD

new matrix of clinical data.

...

further arguments. Currently not used.

Value

newY

the newY containing the n predicted values of the response variables for the observations from newX and newD.

newPi

the newPi containing the n probabilities of the response variables for the observations from newX and newD.

cvg

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

Details

This function is used to obtained predicted values using a model fitting with fit.lspcr.glm. It returns predictions and prediction probabilites in case that the user wants to choose his own decision rule. By default (in the prediction vector) if probabilities are under 0.5 observations are in the 0 class and if probabilities are upper than 0.5 observations are in the 1 class.

See Also

fit.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

#Learn dataset and test dataset (80/20)
index<-preselected.sample(Y,round(length(Y)*0.8))
XL<-X[index,]
XT<-X[-index,]
DL<-D[index,]
DT<-D[-index,]
YL<-Y[index]
#Apply fit.lspcr.glm with 5 components
fit<-fit.lspcr.glm(Y=YL,X=XL,D=DL,ncomp=5)
#predictions
pred<-predict.lspcr.glm(fit,newD=DT,newX=XT)
# }

Run the code above in your browser using DataLab