makeFoldsGLMcv {porridge} | R Documentation |
Generate folds for cross-validation of generalized linear models.
Description
Function that evaluates the targeted ridge estimator of the regression parameter of generalized linear models.
Usage
makeFoldsGLMcv(fold, Y, stratified=TRUE, model="linear")
Arguments
fold |
An |
Y |
A |
stratified |
A |
model |
A |
Value
A list
of length fold
. Each list item is a fold.
Author(s)
W.N. van Wieringen.
Examples
# set the sample size
n <- 50
# set the true parameter
betas <- (c(0:100) - 50) / 20
# generate covariate data
X <- matrix(rnorm(length(betas)*n), nrow=n)
# sample the response
probs <- exp(tcrossprod(betas, X)[1,]) / (1 + exp(tcrossprod(betas, X)[1,]))
Y <- numeric()
for (i in 1:n){
Y <- c(Y, sample(c(0,1), 1, prob=c(1-probs[i], probs[i])))
}
# generate folds
folds <- makeFoldsGLMcv(10, Y, model="logistic")
[Package porridge version 0.3.3 Index]