Skip to contents

Return a model from the cross-validation procedure or the final 'global' model. Caution: This function is still under development.

Usage

# S3 method for metapred
subset(
  x,
  select = "cv",
  step = NULL,
  model = NULL,
  stratum = NULL,
  add = TRUE,
  ...
)

Arguments

x

metapred object

select

Which type of model to select: "cv" (default), "global", or (experimental) "stratified", or "stratum".

step

Which step should be selected? Defaults to the best step. numeric is converted to name of the step: 0 for an unchanged model, 1 for the first change...

model

Which model change should be selected? NULL (default, best change) or character name of variable or (integer) index of model change.

stratum

Experimental. Stratum to return if select = "stratum".

add

Logical. Add data, options and functions to the resulting object? Defaults to TRUE. Experimental.

...

For compatibility only.

Value

An object of class mp.cv for select = "cv" and an object of class mp.global for select = "global". In both cases, additional data is added to the resulting object, thereby making it suitable for further methods.

Author

Valentijn de Jong

Examples

data(DVTipd)
DVTipd$cluster <- letters[1:4] # Add a fictional clustering to the data.
mp <- metapred(DVTipd, strata = "cluster", formula = dvt ~ histdvt + ddimdich, family = binomial)
subset(mp) # best cross-validated model
#> Prediction models estimated in 4 strata. Coefficients:
#>   (Intercept)  ddimdich
#> a   -3.198673  2.135779
#> b   -3.555348  2.251292
#> c  -19.566069 18.540216
#> d   -3.891820  2.947359
#> 
#> Meta-analytic models, estimated in 4 fold combinations. Coefficients: 
#>         (Intercept) ddimdich
#> b, c, d   -3.724268 2.600774
#> a, c, d   -3.432711 2.421694
#> a, b, d   -3.463478 2.377572
#> a, b, c   -3.318460 2.176257
#> 
#> Cross-validation at stratum level yields the following performance: 
#>         val.strata  estimate         se          var      ci.lb     ci.ub
#> b, c, d          a 0.1285223 0.01986149 0.0003944788 0.08921088 0.1678338
#> a, c, d          b 0.1293544 0.01729276 0.0002990394 0.09512723 0.1635816
#> a, b, d          c 0.1123561 0.01717570 0.0002950048 0.07836058 0.1463516
#> a, b, c          d 0.1297595 0.01948263 0.0003795729 0.09119796 0.1683211
#>         measure
#> b, c, d     mse
#> a, c, d     mse
#> a, b, d     mse
#> a, b, c     mse
#> 
#> Generalizability:
#>         1 
#> 0.1244262 
#> 
subset(mp, select = "global") # Final model fitted on all strata.
#> Meta-analytic model of prediction models estimated in 4 strata. Coefficients: 
#> (Intercept)    ddimdich 
#>   -3.463480    2.377574 
subset(mp, step = 1) # The best model of step 1
#> Prediction models estimated in 4 strata. Coefficients:
#>   (Intercept)  ddimdich
#> a   -3.198673  2.135779
#> b   -3.555348  2.251292
#> c  -19.566069 18.540216
#> d   -3.891820  2.947359
#> 
#> Meta-analytic models, estimated in 4 fold combinations. Coefficients: 
#>         (Intercept) ddimdich
#> b, c, d   -3.724268 2.600774
#> a, c, d   -3.432711 2.421694
#> a, b, d   -3.463478 2.377572
#> a, b, c   -3.318460 2.176257
#> 
#> Cross-validation at stratum level yields the following performance: 
#>         val.strata  estimate         se          var      ci.lb     ci.ub
#> b, c, d          a 0.1285223 0.01986149 0.0003944788 0.08921088 0.1678338
#> a, c, d          b 0.1293544 0.01729276 0.0002990394 0.09512723 0.1635816
#> a, b, d          c 0.1123561 0.01717570 0.0002950048 0.07836058 0.1463516
#> a, b, c          d 0.1297595 0.01948263 0.0003795729 0.09119796 0.1683211
#>         measure
#> b, c, d     mse
#> a, c, d     mse
#> a, b, d     mse
#> a, b, c     mse
#> 
#> Generalizability:
#>         1 
#> 0.1244262 
#> 
subset(mp, step = 1, model = "histdvt") # The model in which histdvt was removed, in step 1.
#> Prediction models estimated in 4 strata. Coefficients:
#>   (Intercept)  ddimdich
#> a   -3.198673  2.135779
#> b   -3.555348  2.251292
#> c  -19.566069 18.540216
#> d   -3.891820  2.947359
#> 
#> Meta-analytic models, estimated in 4 fold combinations. Coefficients: 
#>         (Intercept) ddimdich
#> b, c, d   -3.724268 2.600774
#> a, c, d   -3.432711 2.421694
#> a, b, d   -3.463478 2.377572
#> a, b, c   -3.318460 2.176257
#> 
#> Cross-validation at stratum level yields the following performance: 
#>         val.strata  estimate         se          var      ci.lb     ci.ub
#> b, c, d          a 0.1285223 0.01986149 0.0003944788 0.08921088 0.1678338
#> a, c, d          b 0.1293544 0.01729276 0.0002990394 0.09512723 0.1635816
#> a, b, d          c 0.1123561 0.01717570 0.0002950048 0.07836058 0.1463516
#> a, b, c          d 0.1297595 0.01948263 0.0003795729 0.09119796 0.1683211
#>         measure
#> b, c, d     mse
#> a, c, d     mse
#> a, b, d     mse
#> a, b, c     mse
#> 
#> Generalizability:
#>         1 
#> 0.1244262 
#>