cv: Cross validation results for a model

Description Usage Arguments Value Author(s) Examples

Description

Cross validation results for a model

Usage

1
2
3
cv(clinical_x = NULL, genomic_x = NULL, y = NULL, data = NULL,
  clinical_formula = NULL, family = "binomial", folds = NULL, k = 10,
  fit_method = "glm", method_name = NULL, n.cores = 1, ...)

Arguments

clinical_x

clinical variables that will always be included in the model

genomic_x

genomic variables that will be penalized if a penalized model is used

y

response variables

data

dataframe if clinical formula is used

clinical_formula

formula for clinical variables

family

gaussian, binomial or poisson

folds

predefined partions for cross validation

k

number of cross validation folds. A value of k=n is leave one out cross validation.

fit_method

glm or glmnet used to fit the model

method_name

tracking variable to include in return dataframe

n.cores

Number of cores to be used

...

additional commmands to glm or cv.glmnet

Value

returns a dataframe of predicted values and observed values. In addition, method_name is recorded if that variable is defined.

Author(s)

Ben Sherwood <[email protected]>

Examples

1
2
3
4
5
6
x <- matrix(rnorm(800),ncol=8)
y <- runif(100) < exp(1 + x[,1] + x[,5])/(1+exp(1 + x[,1] + x[,5]))
cv_results <- cv(x,y=y,method_name="without_formula")
combined_data <- data.frame(y=y,x1=x[,1],x5=x[,5])
gx <- x[,c(2,3,4,6,7,8)]
cvf <- cv(genomic_x=gx,clinical_formula=y~x1+x5,data=combined_data,method_name="with_form")

Example output

Loading required package: glmnet
Loading required package: Matrix
Loading required package: foreach
Loaded glmnet 2.0-12

Loading required package: parallel
Loading required package: pROC
Type 'citation("pROC")' for a citation.

Attaching package: 'pROC'

The following object is masked from 'package:glmnet':

    auc

The following objects are masked from 'package:stats':

    cov, smooth, var

Warning message:
In data.row.names(row.names, rowsi, i) :
  some row.names duplicated: 11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100 --> row.names NOT used

roccv documentation built on May 10, 2019, 5:03 p.m.