Print an impact or attributable fraction
print.pif_class.Rd
Method for printing a potential impact fraction or a population attributable fraction
Usage
# S3 method for pif_class
print(x, n = 10000, ...)
Arguments
- x
A
pif_class
object- n
Maximum number of simulations to print
- ...
Additional arguments to pass to summary.pif_class
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,
)
print(pifsim)
#> ── Potential Impact Fraction (PIF) ─────────────────────────────────────────────
#> counterfactual relative_risk potential_impact_fraction
#> 1 Counterfactual_1 Relative_Risk_1 0.010532528
#> 2 Counterfactual_1 Relative_Risk_1 -0.001994805
#> 3 Counterfactual_1 Relative_Risk_1 0.023059861
#> average_relative_risk average_counterfactual type
#> 1 1327.588 1316.699 point_estimate
#> 2 -4684.146 -4644.551 Lower 2.5%
#> 3 7339.322 7277.949 Upper 97.5%
#> ────────────────────────────────────────────────────────────────────────────────
#> • Number of bootstrap simulations: 10
#> ✖ A low number of bootstrap simulations will result in an unstable estimate.
#> • Use `as.data.frame` to access values.
#> • Use `summary` to save list of main results.
print(pifsim, n = 1)
#> ── Potential Impact Fraction (PIF) ─────────────────────────────────────────────
#> ℹ Too many simulations to print.
#> ────────────────────────────────────────────────────────────────────────────────
#> • Number of bootstrap simulations: 10
#> ✖ A low number of bootstrap simulations will result in an unstable estimate.
#> • Use `as.data.frame` to access values.
#> • Use `summary` to save list of main results.