paf.plot: Plot of Population Attributable Fraction under different...

Description Usage Arguments Value Author(s) See Also Examples

Description

Function that plots the paf under different values of a univariate parameter theta of the Relative Risk function rr which depends on the exposure X and a theta parameter (rr(X, theta))

Usage

1
2
3
4
5
6
7
8
paf.plot(X, thetalow, thetaup, rr, 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 = "PAF",
  title = "Population Attributable Fraction (PAF) under different values of theta",
  check_exposure = TRUE, check_rr = TRUE, check_integrals = TRUE)

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**

method

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

confidence_method

Either bootstrap (default) inverse, one2one, 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 Colors 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.

Value

paf.plot ggplot object with plot of Population Attributable Fraction as function of theta.

Author(s)

Rodrigo Zepeda-Tello rzepeda17@gmail.com

Dalia Camacho-GarcĂ­a-FormentĂ­ daliaf172@gmail.com

See Also

See paf for Population Attributable Fraction estimation with confidence intervals paf.confidence.

See pif.plot for same plot with Potential Impact Fraction pif.

Examples

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


#Same example with kernel method
paf.plot(X, 0, 2, function(X, theta){exp(theta*X)}, method = "kernel",
title = "Kernel method example") 
 
#Same example for approximate method
Xmean <- data.frame(mean(X[,"Exposure"]))
Xvar  <- var(X)
paf.plot(Xmean, 0, 2, function(X, theta){exp(theta*X)}, 
method = "approximate", Xvar = Xvar, title = "Approximate method example")

## End(Not run)

INSP-RH/pif documentation built on May 7, 2019, 6:01 a.m.