Learn R Programming

metamisc (version 0.1.9)

metapred: Generalized Stepwise Regression for prediction models

Description

Generalized stepwise regression for obtaining a prediction model with adequate performance across data sets. Requires data from individuals in multiple studies.

Usage

metapred(data, strata, formula = NULL, estFUN = "glm", stepwise = TRUE,
  center.out = FALSE, center.cov = FALSE, recal.int = FALSE,
  cvFUN = NULL, cv.k = NULL, metaFUN = NULL, meta.method = "REML",
  predFUN = NULL, perfFUN = NULL, genFUN = NULL, selFUN = "which.min",
  ...)

Arguments

data

data.frame containing the datasets.

strata

Name of the strata (e.g. studies or clusters) variable, as character. Used for two-stage MA only.

formula

Formula of the full model to be evaluated, and possibly reduced. If not supplied, it is assumed the first column in the data set is the outcome, and all remaining columns (except strata) are predictors. See formula for details.

estFUN

Function for estimating the model in the first stage. Currently "lm" and "glm" are supported.

stepwise

Logical. Should stepwise selection be performed?

center.out

Logical. Should the outcome be centered within studies?

center.cov

Logical. Should covariates be centered within studies?

recal.int

Logical. Should the intercept be recalibrated?

cvFUN

Cross-validation method, on the study (i.e. cluster or stratum) level. " l1o" for leave-one-out cross-validation (default). "bootstrap" for bootstrap. Or "fixed", for one or more data sets which are only used for validation. A user written function may be supplied as well.

cv.k

Parameter for cvFUN. For cvFUN="bootstrap", this is the number of bootstraps. For cvFUN="fixed", this is a vector of the indices of the (sorted) data sets.

metaFUN

Function for computing the meta-analytic coefficient estimates in two-stage MA. Default: rma from the metafor package is used. Default settings are univariate random effects, estimated with "REML". Method can be passed trough the meta.method argument.

meta.method

Name of method for meta-analysis. Default is "REML". For more options see rma.

predFUN

Function for predicting new values. Defaults to the appropriate link functions for two-stage MA where glm() or lm() is used in the first stage. For one-stage models predict() is used.

perfFUN

Function for computing the performance of the prediction models. Default: mean squared error (perfFUN="mse"). Other options are "vare".

genFUN

Function computing generalizability measure using the performance measures. Default: (absolute) mean (genFUN="absmean"). Choose squareddiff for a penalty equal to the mean squared differences between coefficients. Alternatively, choose pooledvar for a weighted average of variance terms.

selFUN

Function for selecting the best method. Default: lowest value for genFUN. Should be set to "which.max" if high values for genFUN indicate a good model.

...

To pass arguments to estFUN (e.g. family = "binomial"), or other methods.

Value

metapred A list of class metapred, containing the final coefficients in coefficients, and the stepwise tree of estimates of the coefficients (coef), performance measures (perf), generalizability measures (gen) in stepwise, and more.

References

Debray TPA, Moons KGM, Ahmed I, Koffijberg H, Riley RD. A framework for developing, implementing, and evaluating clinical prediction models in an individual participant data meta-analysis. Stat Med. 2013;32(18):3158-80.

Examples

Run this code
# NOT RUN {
data(DVTipd)
DVTipd$cluster <- 1:4 # Add a fictional clustering to the data set.
metamisc:::metapred(DVTipd, strata = "cluster", f = dvt ~ sex + vein + malign, family = binomial)

# }
# NOT RUN {
# Some additional examples:
metamisc:::metapred(DVTipd, strata = "cluster", f = dvt ~ sex + vein + malign
, family = binomial, stepwise = FALSE)
metamisc:::metapred(DVTipd, strata = "cluster", f = dvt ~ sex + altdiagn + histdvt
, family = binomial, recal.int = TRUE)
metamisc:::metapred(DVTipd, strata = "cluster", f = dvt ~ sex + altdiagn + histdvt
, family = binomial, meta.method = "DL")
# }
# NOT RUN {
# By default, metapred assumes the first column is the outcome.
DVTipd.reordered <- DVTipd[c("dvt", "ddimdich", "histdvt", "cluster")]
mp <- metamisc:::metapred(DVTipd.reordered, strata = "cluster", family = binomial)
fitted <- predict(mp, newdata = DVTipd.reordered)


# }

Run the code above in your browser using DataLab