pif.variance.approximate.linear: Approximate Variance for the Potential Impact Fraction using...

Description Usage Arguments Author(s) See Also Examples

View source: R/pif_variance_approximate_linear.R

Description

Function that calculates approximate variance to the potential impact fraction.

Usage

1
2
3
4
5
pif.variance.approximate.linear(X, thetahat, rr, thetavar, Xvar, cft = NA,
  check_thetas = TRUE, check_cft = TRUE, check_xvar = TRUE,
  check_rr = TRUE, check_integrals = TRUE, check_exposure = TRUE,
  deriv.method.args = list(), deriv.method = c("Richardson", "complex"),
  nsim = 1000, is_paf = FALSE)

Arguments

X

Mean value of exposure levels from a cross-sectional random sample.

thetahat

Estimator (vector or matrix) of theta for the Relative Risk function.

rr

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

**Optional**

thetavar

Estimator of variance of thetahat

Xvar

Variance of exposure levels.

cft

Function cft(X) for counterfactual. Leave empty for the Population Attributable Fraction paf where counterfactual is 0 exposure.

check_thetas

Checks that theta parameters are correctly inputed

check_cft

Check if counterfactual function cft reduces exposure.

check_xvar

Check if it is covariance matrix.

check_rr

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

check_integrals

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

check_exposure

Check that exposure X is positive and numeric

deriv.method.args

method.args for hessian.

deriv.method

method for hessian. Don't change this unless you know what you are doing.

nsim

Number of simulations for estimation of variance

is_paf

Force evaluation as paf

Author(s)

Rodrigo Zepeda-Tello rzepeda17@gmail.com

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

See Also

pif.variance.linear for pif variance and pif.confidence for confidence intervals of pif

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
## Not run: 
#Example 1: Exponential Relative risk
#--------------------------------------------
set.seed(46987)
rr       <- function(X,theta){exp(X*theta)}
cft      <- function(X){0.5*X}
X        <- rbeta(100, 2, 3)
Xmean    <- data.frame(mean(X))
Xvar     <- var(X)
theta    <- 1.2
thetavar <- 0.15
pif.variance.approximate.linear(Xmean, theta, rr, thetavar, Xvar, cft) 

#Example 2: Multivariate example
#--------------------------------------------
X1       <- rnorm(1000,3,.5)
X2       <- rnorm(1000,4,1)
X        <- data.frame(cbind(X1,X2))
Xmean    <- matrix(colMeans(X), ncol = 2)
Xvar     <- cov(X)
theta    <- c(0.12, 0.17)
thetavar  <- matrix(c(0.001, 0.00001, 0.00001, 0.004), byrow = TRUE, nrow = 2)
rr       <- function(X, theta){exp(theta[1]*X[,1] + theta[2]*X[,2])}
pif.variance.approximate.linear(Xmean, theta, rr, thetavar, Xvar,
cft = function(X){cbind(0.5*X[,1],0.4*X[,2])}, check_integrals = FALSE)

## End(Not run)

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