Skip to contents

Method for obtaining the variance of bootstrap simulations of a x object (i.e. the point-estimate of the potential impact fraction or population attributable fraction via the bootstrap).

Usage

var_bootstrap(x, ...)

Arguments

x

A pif_class object

...

additional arguments to pass to stats::var()

Examples

#Example 1
data(ensanut)
options(survey.lonely.psu = "adjust")
design <- survey::svydesign(data = ensanut, ids = ~1, weights = ~weight, strata = ~strata)
rr <- function(X, theta) {
  exp(-2 +
    theta[1] * X[, "age"] + theta[2] * X[, "systolic_blood_pressure"] / 100)
}
cft <- function(X) {
  X[, "systolic_blood_pressure"] <- X[, "systolic_blood_pressure"] - 5
  return(X)
}
pifsim <- pif(design,
  theta = log(c(1.05, 1.38)), rr, cft,
  additional_theta_arguments = c(0.01, 0.03), n_bootstrap_samples = 10,
)
var_bootstrap(pifsim)
#>     counterfactual   relative_risk potential_impact_fraction
#> 1 Counterfactual_1 Relative_Risk_1              4.357334e-05
#>   average_relative_risk average_counterfactual
#> 1          1.454987e+13           1.436173e+13