Skip to contents

Method for transforming a potential impact fraction or a population attributable fraction to a data.frame

Usage

# S3 method for pif_class
as.data.frame(x, ...)

Arguments

x

A pif_class object

...

Additional methods 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,
)
#> Loading required package: foreach
#> Loading required package: future
as.data.frame(pifsim)
#>     counterfactual   relative_risk potential_impact_fraction
#> 1 Counterfactual_1 Relative_Risk_1               0.016495618
#> 2 Counterfactual_1 Relative_Risk_1               0.005181433
#> 3 Counterfactual_1 Relative_Risk_1               0.027809803
#>   average_relative_risk average_counterfactual           type
#> 1              142.4008               140.6641 point_estimate
#> 2             -594.5198              -587.7990     Lower 2.5%
#> 3              879.3214               869.1272    Upper 97.5%