nested.glm {nestfs} | R Documentation |
Cross-validated generalized linear models
Description
Run linear or logistic regression on a set of cross-validation folds. This can be used to establish a baseline model, often built only on the initial set of covariates.
Usage
nested.glm(formula, data, family, folds, store.glm = FALSE)
Arguments
formula |
An object of class |
data |
Data frame or matrix containing outcome variable and predictors. |
family |
Type of model fitted: either |
folds |
List of cross-validation folds, where each element contains the indices of the observations to be withdrawn in that fold. |
store.glm |
Whether the object produced by |
Value
An object of class nestglm
of length equal to length(folds)
,
where each entry contains the following fields:
summary |
Summary of the coefficients of the model fitted on the training observations. |
family |
Type of model fitted. |
fit |
Predicted values for the withdrawn observations. |
obs |
Observed values for the withdrawn observations. |
test.llk |
Test log-likelihood. |
test.idx |
Indices of the the withdrawn observations for this fold. |
regr |
Object created by |
See Also
Examples
data(diabetes)
folds <- create.folds(10, nrow(diabetes), seed=1)
res <- nested.glm(Y ~ age + sex + bmi + map, diabetes, gaussian(), folds)