
Change the link for the fraction's variance calculation
change_link.Rd
Change the link function for the potential impact fraction or population attributable fraction to a different link.
Arguments
- x
A
pif_class
object- link
Link function such that the
pif
confidence intervals stays within the expected bounds.- link_inv
The inverse of
link
. For example iflink
islogit
this should beinv_logit
.- link_deriv
Derivative of the
link
function. The function tries to build it automatically fromlink
usingDeriv::Deriv()
.
Examples
#A potential impact fraction
pif1 <- pif(p = 0.2, p_cft = 0.1, beta = 1.2, var_p = 0.01,
var_beta = 0.2)
pif1
#>
#> ── Potential Impact Fraction ──
#>
#> PIF = 1.923% [95% CI: -7.401% to 10.438%]
#> standard_deviation(pif %) = 4.545
#> standard_deviation(link(pif)) = 0.046
#Now change the pif to logit to control the negatives
pif1_logit <- change_link(pif1, link = "logit")
pif1_logit
#>
#> ── Potential Impact Fraction ──
#>
#> PIF = 1.923% [95% CI: 0.017% to 68.800%]
#> standard_deviation(pif %) = 4.545
#> standard_deviation(link(pif)) = 2.410