Skip to contents

Change the link function for the potential impact fraction or population attributable fraction to a different link.

Usage

change_link(x, link = "identity", link_inv = NULL, link_deriv = NULL)

Arguments

x

A pif_class object

Link function such that the pif confidence intervals stays within the expected bounds.

The inverse of link. For example if link is logit this should be inv_logit.

Derivative of the link function. The function tries to build it automatically from link using Deriv::Deriv().

Value

A pif_class object with a different link.

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