# NOT RUN {
# }
# NOT RUN {
# Start the graphics device driver to save all plots in a pdf format
pdf(file = "FRESA.Model.Example.pdf",width = 8, height = 6)
# Get the stage C prostate cancer data from the rpart package
data(stagec,package = "rpart")
options(na.action = 'na.pass')
stagec_mat <- cbind(pgstat = stagec$pgstat,
pgtime = stagec$pgtime,
as.data.frame(model.matrix(Surv(pgtime,pgstat) ~ .,stagec))[-1])
data(cancerVarNames)
dataCancerImputed <- nearestNeighborImpute(stagec_mat)
# Get a Cox proportional hazards model using:
# - The default parameters
md <- FRESA.Model(formula = Surv(pgtime, pgstat) ~ 1,
data = dataCancerImputed,
var.description = cancerVarNames[,2])
pt <- plot(md$bootstrappedModel)
sm <- summary(md$BSWiMS.model)
print(sm$coefficients)
# Get a 10 fold CV Cox proportional hazards model using:
# - Repeat 10 times de CV
md <- FRESA.Model(formula = Surv(pgtime, pgstat) ~ 1,
data = dataCancerImputed, CVfolds = 10,
repeats = 10,
var.description = cancerVarNames[,2])
pt <- plotModels.ROC(md$cvObject$Models.testPrediction,theCVfolds = 10)
print(pt$predictionTable)
pt <- plotModels.ROC(md$cvObject$LASSO.testPredictions,theCVfolds = 10)
pt <- plotModels.ROC(md$cvObject$KNN.testPrediction,theCVfolds = 10)
# Get a regression of the survival time
timeSubjects <- dataCancerImputed
timeSubjects$pgtime <- log(timeSubjects$pgtime)
md <- FRESA.Model(formula = pgtime ~ 1,
data = timeSubjects,
var.description = cancerVarNames[,2])
pt <- plot(md$bootstrappedModel)
sm <- summary(md$BSWiMS.model)
print(sm$coefficients)
# Get a logistic regression model using
# - The default parameters and removing time as possible predictor
dataCancerImputed$pgtime <- NULL
md <- FRESA.Model(formula = pgstat ~ 1,
data = dataCancerImputed,
var.description = cancerVarNames[,2])
pt <- plot(md$bootstrappedModel)
sm <- summary(md$BSWiMS.model)
print(sm$coefficients)
# Get a logistic regression model using:
# - residual-based optimization
md <- FRESA.Model(formula = pgstat ~ 1,
data = dataCancerImputed,
OptType = "Residual",
var.description = cancerVarNames[,2])
pt <- plot(md$bootstrappedModel)
sm <- summary(md$BSWiMS.model)
print(sm$coefficients)
# Shut down the graphics device driver
dev.off()
# }
Run the code above in your browser using DataLab