View source: R/ridgeGLMandCo.R
makeFoldsGLMcv | R Documentation |
Function that evaluates the targeted ridge estimator of the regression parameter of generalized linear models.
makeFoldsGLMcv(fold, Y, stratified=TRUE, model="linear")
fold |
An |
Y |
A |
stratified |
A |
model |
A |
A list
of length fold
. Each list item is a fold.
W.N. van Wieringen.
# 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.