This learner augments a set of screened covariates with covariates that should be included by default, even if the screener did not select them.

Format

R6Class object.

Value

Learner object with methods for training and prediction. See Lrnr_base for documentation on learners.

Parameters

screener

An instantiated screener.

default_covariates

Vector of covariate names to be automatically added to the vector selected by the screener, regardless of whether or not these covariates were selected by the screener.

...

Other parameters passed to screener.

Examples

library(data.table)

# load example data
data(cpp_imputed)
setDT(cpp_imputed)
cpp_imputed[, parity_cat := factor(ifelse(parity < 4, parity, 4))]
#>       subjid agedays   wtkg htcm lencm      bmi        waz        haz   whz
#>    1:      1       1  4.621   55    55 15.27603  2.3800000  2.6100000  0.19
#>    2:      1     366 14.500   79    79 23.23346  3.8400000  1.3500000  4.02
#>    3:      2       1  3.345   51    51 12.86044  0.0600000  0.5000000 -0.64
#>    4:      2     366  8.400   73    73 15.76281 -1.2700000 -1.1700000 -0.96
#>    5:      2    2558 19.100  114     0 14.69683 -1.3727316 -1.4664795  0.00
#>   ---                                                                      
#> 1437:    500       1  3.629   52    52 13.42086  0.8900000  1.4400000 -0.49
#> 1438:    500     366 10.900   77    77 18.38421  1.5700000  1.1500000  1.47
#> 1439:    500    2558 26.300  126     0 16.56589  0.9932827  0.9455342  0.00
#> 1440:    501       1  3.232   46    46 15.27410 -0.1800000 -2.1400000  2.27
#> 1441:    501     366  9.700   77    77 16.36026  0.0400000  0.5100000 -0.24
#>         baz siteid sexn    sex feedingn feeding gagebrth birthwt birthlen
#>    1:  1.35      5    1   Male       90 Unknown      287    4621       55
#>    2:  3.89      5    1   Male       90 Unknown      287    4621       55
#>    3: -0.43      5    1   Male       90 Unknown      280    3345       51
#>    4: -0.80      5    1   Male       90 Unknown      280    3345       51
#>    5:  0.00      5    1   Male       90 Unknown      280    3345       51
#>   ---                                                                    
#> 1437:  0.08      5    2 Female       90 Unknown      287    3629       52
#> 1438:  1.30      5    2 Female       90 Unknown      287    3629       52
#> 1439:  0.00      5    2 Female       90 Unknown      287    3629       52
#> 1440:  1.35      5    1   Male       90 Unknown      287    3232       46
#> 1441: -0.33      5    1   Male       90 Unknown      287    3232       46
#>       apgar1 apgar5 mage mracen mrace mmaritn  mmarit meducyrs sesn
#>    1:      8      9   21      5 White       1 Married       12   50
#>    2:      8      9   21      5 White       1 Married       12   50
#>    3:      8      9   15      5 White       1 Married        0    0
#>    4:      8      9   15      5 White       1 Married        0    0
#>    5:      8      9   15      5 White       1 Married        0    0
#>   ---                                                              
#> 1437:      6      9   20      5 White       1 Married       11   38
#> 1438:      6      9   20      5 White       1 Married       11   38
#> 1439:      6      9   20      5 White       1 Married       11   38
#> 1440:      5      9   19      5 White       1 Married        9   50
#> 1441:      5      9   19      5 White       1 Married        9   50
#>                ses parity gravida smoked mcignum comprisk parity_cat
#>    1:       Middle      1       1      0       0     none          1
#>    2:       Middle      1       1      0       0     none          1
#>    3:            .      0       0      1      35     none          0
#>    4:            .      0       0      1      35     none          0
#>    5:            .      0       0      1      35     none          0
#>   ---                                                               
#> 1437: Lower-middle      0       0      1      10     none          0
#> 1438: Lower-middle      0       0      1      10     none          0
#> 1439: Lower-middle      0       0      1      10     none          0
#> 1440:       Middle      1       1      0       0     none          1
#> 1441:       Middle      1       1      0       0     none          1
covars <- c(
  "apgar1", "apgar5", "parity_cat", "gagebrth", "mage", "meducyrs",
  "sexn"
)
outcome <- "haz"

# create sl3 task
task <- sl3_Task$new(data.table::copy(cpp_imputed),
  covariates = covars,
  outcome = outcome
)

screener_cor <- make_learner(
  Lrnr_screener_correlation,
  type = "rank",
  num_screen = 2
)
screener_augment <- Lrnr_screener_augment$new(screener_cor, covars)
screener_fit <- screener_augment$train(task)
selected <- screener_fit$fit_object$selected
screener_selected <- screener_fit$fit_object$screener_selected