Last data update: 2014.03.03

R: Cross-Validation for Regression with a Binary Response
CVbinaryR Documentation

Cross-Validation for Regression with a Binary Response

Description

These functions give training (internal) and cross-validation measures of predictive accuracy for regression with a binary response. The data are randomly divided between a number of ‘folds’. Each fold is removed, in turn, while the remaining data are used to re-fit the regression model and to predict at the omitted observations.

Usage

CVbinary(obj, rand=NULL, nfolds=10, print.details=TRUE)

cv.binary(obj, rand=NULL, nfolds=10, print.details=TRUE)

Arguments

obj

a glm object

rand

a vector which assigns each observation to a fold

nfolds

the number of folds

print.details

logical variable (TRUE = print detailed output, the default)

Value

cvhat

predicted values from cross-validation

internal

internal or (better) training predicted values

training

training predicted values

acc.cv

cross-validation estimate of accuracy

acc.internal

internal or (better) training estimate of accuracy

acc.training

training estimate of accuracy

Note

The term ‘training’ seems preferable to the term ‘internal’ in connection with predicted values, and the accuracy measure, that are based on the observations used to derive the model.

Author(s)

J.H. Maindonald

See Also

glm

Examples

frogs.glm <- glm(pres.abs ~ log(distance) + log(NoOfPools),
                 family=binomial,data=frogs)
CVbinary(frogs.glm)
mifem.glm <- glm(outcome ~ ., family=binomial, data=mifem)
CVbinary(mifem.glm)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(DAAG)
Loading required package: lattice
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/DAAG/CVbinary.Rd_%03d_medium.png", width=480, height=480)
> ### Name: CVbinary
> ### Title: Cross-Validation for Regression with a Binary Response
> ### Aliases: CVbinary cv.binary
> ### Keywords: models
> 
> ### ** Examples
> 
> frogs.glm <- glm(pres.abs ~ log(distance) + log(NoOfPools),
+                  family=binomial,data=frogs)
> CVbinary(frogs.glm)

Fold:  2 9 5 6 7 3 10 4 1 8
Internal estimate of accuracy = 0.759
Cross-validation estimate of accuracy = 0.755
> mifem.glm <- glm(outcome ~ ., family=binomial, data=mifem)
> CVbinary(mifem.glm)

Fold:  8 7 1 3 10 2 6 4 5 9
Internal estimate of accuracy = 0.807
Cross-validation estimate of accuracy = 0.803
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>