Executes k-fold cross-validation for DMR and returns a value for df.
cv.DMRnet(
X,
y,
family = "gaussian",
o = 5,
nlambda = 100,
lam = 10^(-7),
interc = TRUE,
maxp = ifelse(family == "gaussian", ceiling(length(y)/2), ceiling(length(y)/4)),
nfolds = 10,
indexation.mode = "GIC",
algorithm = "DMRnet",
clust.method = ifelse(algorithm == "glamer", "single", "complete")
)
An object with S3 class "cv.DMR" is returned, which is a list with the ingredients of the cross-validation fit.
df (number of parameters) of the model with minimal cross-validated error.
df (number of parameters) of the smallest model falling under the upper curve of a prediction error plus one standard deviation.
Fitted DMR
object for the full data.
The mean cross-validated error for the entire sequence of models.
The fold assignments used.
Input data frame, of dimension n x p; each row is an observation vector. Columns can be numerical or integer for continuous predictors or factors for categorical predictors.
Response variable. Numerical for family="gaussian"
or a factor with two levels for family="binomial"
. For family="binomial"
the last level in alphabetical order is the target class.
Response type; one of: "gaussian"
, "binomial"
.
Parameter of the group lasso screening step, described in DMRnet
.
Parameter of the group lasso screening step, described in DMRnet
. The default value is 100.
The amount of penalization in ridge regression (used for logistic regression in order to allow for parameter estimation in linearly separable setups) or the amount of matrix regularization in case of linear regression. Used only for numerical reasons. The default value is 1e-7.
Should intercept(s) be fitted (the default, interc=TRUE
) or set to zero (interc=FALSE
). If in X
there are any categorical variables, interc=TRUE
must be set.
Maximal number of parameters of the model, smaller values result in quicker computation.
Number of folds in cross-validation. The default value is 10.
How the cross validation algorithm should index the models for internal quality comparisons; one of: "GIC"
(the default) for GIC-indexed cross validation, "dimension"
, for model dimension-indexed cross validation.
The algorithm to be used; for partition selection (merging levels) use one of: "DMRnet"
(the default), "glamer"
or "PDMR"
. Alternatively, use "var_sel"
for variable (group) selection with no partition selection.
Clustering method used for partitioning levels of factors; see function hclust in package stats for details. clust.method="complete"
is the default for all algorithms except algorithm="glamer"
, for which clust.method="single"
is the default.
cv.DMRnet algorithm does nfold
-fold cross-validation for DMRnet. The df for the minimal estimated prediction error is returned.
plot.cv.DMR
for plotting, coef.cv.DMR
for extracting coefficients and predict.cv.DMR
for prediction.
## cv.DMRnet for linear regression
set.seed(13)
data(miete)
ytr <- miete$rent[1:1500]
Xtr <- miete$area[1:1500]
Xte <- miete$area[1501:2053]
cv <- cv.DMRnet(Xtr, ytr)
print(cv)
plot(cv)
coef(cv)
ypr <- predict(cv, newx = Xte)
Run the code above in your browser using DataLab