pif.plot: Plot of Potential Impact Fraction under different values of...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/pif_plot.R

Description

Function that plots the pif under different values of a univariate parameter theta of the relative risk function rr which depends on the exposure X and a parameter theta (rr(X, theta))

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
pif.plot(X, thetalow, thetaup, rr, cft = NA, method = "empirical",
  confidence_method = "bootstrap", confidence = 95, nsim = 100,
  weights = rep(1/nrow(as.matrix(X)), nrow(as.matrix(X))), mpoints = 100,
  adjust = 1, n = 512, Xvar = var(X), deriv.method.args = list(),
  deriv.method = "Richardson", ktype = "gaussian", bw = "SJ",
  colors = c("deepskyblue", "gray25"), xlab = "Theta", ylab = "PIF",
  title = "Potential Impact Fraction (PIF) under different values of theta",
  check_exposure = TRUE, check_rr = TRUE, check_integrals = TRUE,
  check_cft = TRUE, check_thetas = TRUE, check_xvar = TRUE,
  is_paf = FALSE)

Arguments

X

Random sample (data.frame) which includes exposure and covariates or sample mean if "approximate" method is selected.

thetalow

Minimum of theta (parameter of relative risk rr) for plot.

thetaup

Maximum of theta (parameter of relative risk rr) for plot.

rr

function for Relative Risk which uses parameter theta. The order of the parameters should be rr(X, theta).

**Optional**

cft

Function cft(X) for counterfactual. Leave empty for the Population Attributable Fraction paf where counterfactual is that of the theoretical minimum risk exposure X0 such that rr(X0,theta) = 1.

method

Either "empirical" (default), "kernel" or "approximate". For details on estimation methods see pif.

confidence_method

Either bootstrap (default), linear, loglinear. See paf details for additional information.

confidence

Confidence level % (default 95).

nsim

Number of simulations to generate confidence intervals.

weights

Normalized survey weights for the sample X.

mpoints

Number of points in plot.

adjust

Adjust bandwith parameter (for "kernel" method) from density.

n

Number of equally spaced points at which the density (for "kernel" method) is to be estimated (see density).

Xvar

Variance of exposure levels (for "approximate" method).

deriv.method.args

method.args for hessian (for "approximate" method).

deriv.method

method for hessian. Don't change this unless you know what you are doing (for "approximate" method).

ktype

kernel type: "gaussian", "epanechnikov", "rectangular", "triangular", "biweight", "cosine", "optcosine" (for "kernel" method). Additional information on kernels in density.

bw

Smoothing bandwith parameter (for "kernel" method) from density. Default "SJ".

colors

vector Colours of plot.

xlab

string Label of x-axis in plot.

ylab

string Label of y-axis in plot.

title

string Title of plot.

check_exposure

boolean Check that exposure X is positive and numeric.

check_rr

boolean Check that Relative Risk function rr equals 1 when evaluated at 0.

check_integrals

boolean Check that counterfactual cft and relative risk's rr expected values are well defined for this scenario.

check_cft

boolean Check that counterfactual function cft reduces exposure.

check_thetas

boolean Check that theta associated parameters are correctly inputed for the model.

check_xvar

boolean Check Xvar is covariance matrix.

is_paf

Boolean forcing evaluation of paf. This forces the pif function ignore the inputed counterfactual and set it to the theoretical minimum risk value of 1.

Value

pif.plot ggplot object with plot of Potential Impact Fraction as function of theta.

Author(s)

Rodrigo Zepeda-Tello rzepeda17@gmail.com

Dalia Camacho-Garc<c3><ad>a-Forment<c3><ad> daliaf172@gmail.com

See Also

See pif for Potential Impact Fraction estimation with confidence intervals pif.confidence.

See paf.plot for same plot with Population Attributable Fraction paf.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#Example 1: Exponential Relative Risk empirical method
#-----------------------------------------------------
## Not run: 
set.seed(18427)
X <- data.frame(Exposure = rbeta(25, 4.2, 10))
pif.plot(X, thetalow = 0, thetaup = 10, rr =  function(X, theta){exp(theta*X)})

#Same example with kernel method
pif.plot(X, thetalow = 0, thetaup = 10, rr =  function(X, theta){exp(theta*X)}, 
method = "kernel", title = "Kernel method example") 
 
#Same example for approximate method. Notice that approximate method has 
#more uncertainty
Xmean <- data.frame(mean(X[,"Exposure"]))
Xvar  <- var(X)
pif.plot(Xmean, thetalow = 0, thetaup = 10, rr =  function(X, theta){exp(theta*X)}, 
method = "approximate", Xvar = Xvar, title = "Approximate method example")

#Example with counterfactual
pif.plot(X, thetalow = -10, thetaup = -5, rr = function(X, theta){exp(theta*X)}, 
cft = function(X){sqrt(X)})

#Example for approximate method with square root counterfactual
#Notice how the approximate represents information loss and thus the interval
#loses precision.
pif.plot(Xmean, thetalow = -10, thetaup = -5, rr = function(X, theta){exp(theta*X)},  
cft = function(X){sqrt(X)}, method = "approximate", Xvar = Xvar) 

## End(Not run)

pifpaf documentation built on May 1, 2019, 9:11 p.m.