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

Description Usage Arguments Author(s) See Also Examples

View source: R/pif_variance_linear.R

Description

Function that calculates approximate variance of the potential impact fraction pif (linearization).

Usage

1
2
3
4
pif.variance.linear(X, thetahat, rr, thetavar, cft = NA,
  weights = rep(1/nrow(as.matrix(X)), nrow(as.matrix(X))),
  check_thetas = TRUE, check_cft = TRUE, check_exposure = TRUE,
  nsim = 1000, is_paf = FALSE)

Arguments

X

Random sample (data.frame) which includes exposure and covariates.

thetahat

Estimator (vector) 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

cft

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

weights

Normalized survey weights for the sample X.

check_thetas

Checks that theta parameters are correctly inputed

check_cft

Check if counterfactual function cft reduces exposure.

check_exposure

Check that exposure X is positive and numeric

nsim

Number of simulations for estimation of variance

is_paf

Boolean to force paf evaluation.

Author(s)

Rodrigo Zepeda-Tello [email protected]

Dalia Camacho-Garc<c3><ad>a-Forment<c3><ad> [email protected]

See Also

pif.variance.approximate.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
28
29
30
31
#Example 1: Exponential Relative risk
#--------------------------------------------
set.seed(18427)
X <- data.frame(rnorm(100,3,.5))
thetahat <- 0.12
thetavar <- 0.1
pif.variance.linear(X, thetahat, function(X, theta){exp(theta*X)}, 
                    thetavar, nsim = 100) 

#Same example with linear counterfactual
cft      <- function(X){0.3*X}
pif.variance.linear(X, thetahat, function(X, theta){exp(theta*X)}, 
                    thetavar, cft, nsim = 100) 
                    
#Example 2: Multivariate case
#--------------------------------------------
## Not run: 
set.seed(18427)
X1 <- rnorm(100, 3,.5)
X2 <- runif(100, 1, 1.5)
X  <- data.frame(cbind(X1,X2))
thetahat <- c(0.1, 0.03)
thetavar <- matrix(c(0.1, 0, 0, 0.05), byrow = TRUE, nrow = 2)
rr        <- function(X, theta){
           .X <- as.matrix(X, ncol = 2)
           exp(theta[1]*.X[,1] + theta[2]*.X[,2])
           }
cft <- function(X){0.5*X}
pif.variance.linear(X, thetahat, rr, thetavar, cft, nsim = 100) 

## End(Not run)

pifpaf documentation built on Sept. 29, 2017, 1:03 a.m.