Learn R Programming

pact (version 0.5.0)

pact.cv: Cross-validation for pact

Description

Predictive scores using k-fold cross-validation for the model developed in pact.fit

Usage

pact.cv(p, nfold)

Arguments

p
An object of class 'pact'
nfold
The number of folds (k) for the k-fold cross-validation. k equal to the sample size would mean a leave-one-out cross-validation

Value

A list with the following components
PredScore
The cross-validated scores for each subject (a vector)
Y
The response variable used
Xf
The dataframe of fixed prognostic covariates
Xv
The dataframe of candidate predictive variables
Treatment
The treatment assignment indicator used
nCovarf
The number of variables in Xf
nCovarv
The number of variables in Xv
family
Type of the response variable
varSelect
The variable selection method used
nsig, cvfolds.varSelect, which.lambda, penalty.scaling
The variable selection parameters used
call
The call that produced this output

Details

Obtain cross-validated predictive scores for the model developed in pact.fit. In each fold of the cross-validation, a model is developed from the observations in the training set using the same variable selection parameters as that used for the model developed in pact.fit. The estimated coefficients of the regression model developed using training set are used to make predictions for the left out observations (test set). This is repeated for all the folds. Scores are thus obtained for all the subjects in the dataset. The function eval.pact.cv provides various evaluation options for the cross-validated scores.

Examples

Run this code
data(prostateCancer)
Y <- prostateCancer[,3:4]
Xf <- prostateCancer[,7:8]
Xv <- prostateCancer[,c(5:6,9)]
Treatment <- as.factor(prostateCancer[,2])
p <- pact.fit(Y=Y,Xf=Xf,Xv=Xv,Treatment=Treatment,family="cox",varSelect="lasso")
cv <- pact.cv(p, nfold=5)

Run the code above in your browser using DataLab