R/benchmarks.R
dml_benchmark.RdCompute benchmarks for the strength of latent variables, under the assumption that the gains in explanatory power due to latent variables is proportional to the gains of observed covariates.
dml_benchmark(model, benchmark_covariates, dreg = NULL, yreg = NULL)an object of class dml.
the observed covariates to benchmark. Either a
character vector of column names in the model's x (each benchmarked
on its own), or a named list where each element is a character vector of
column names to drop together in the refit (e.g. the
dummy columns of a factor: list(region = c("region3", "region4"))).
List element names become the row labels; unnamed elements are labelled by
the column name (singletons) or the columns joined by "+".
optional learner specifications (as in dml) for
the refit, overriding those stored in model$call.
An object of class dml_benchmark containing benchmark results.
data("pension")
set.seed(3); idx <- sample(nrow(pension), 2000)
y <- pension$net_tfa[idx]
d <- pension$e401[idx]
x <- model.matrix(~ -1 + age + inc + educ + fsize + marr + twoearn + pira + hown,
data = pension[idx, ])
fit <- dml(y, d, x, model = "plm", cf.folds = 2, cf.seed = 3, verbose = FALSE)
# observed gains of income, from a refit without it
bench <- dml_benchmark(fit, benchmark_covariates = "inc")
#>
#> === Computing benchmarks using covariate: inc ===
#>
summary(bench)
#> Covariate benchmarks:
#>
#> gain.Y se.gain.Y gain.D se.gain.D rho se.rho delta se.delta
#> inc 0.1899 0.0687 0.0332 0.0104 -0.3338 0.1087 -3092.902 952.4735
#>
#> Combined across cross-fitting repetitions using the median method.