# pif.conditional.variance.linear: Conditional Variance for the Potential Impact Fraction In pifpaf: Potential Impact Fraction and Population Attributable Fraction for Cross-Sectional Data

## Description

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

## Usage

 ```1 2 3``` ```pif.conditional.variance.linear(X, thetahat, rr, cft = NA, weights = rep(1/nrow(as.matrix(X)), nrow(as.matrix(X))), check_cft = TRUE, 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** `cft` Function `cft(X)` for counterfactual. Leave empty for the Population Attributable Fraction `PAF` where counterfactual is 0 exposure. `weights` Survey `weights` for the random sample `X`. `check_cft` Check if counterfactual function `cft` reduces exposure. `is_paf` Force evaluation of `paf`

## Author(s)

Rodrigo Zepeda-Tello [email protected]

`pif.variance.linear` for `pif` variance without conditioning on `theta` and `pif.variance.loglinear` for variance of `log(pif)`
 ``` 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``` ```#Example 1: Exponential Relative risk #-------------------------------------------- set.seed(18427) X <- data.frame(rnorm(100,3,.5)) thetahat <- 0.12 rr <- function(X, theta){exp(theta*X)} #When no counterfactual is specified calculates PAF pif.conditional.variance.linear(X, thetahat, rr) #Example with linear counterfactual cft <- function(X){0.3*X} pif.conditional.variance.linear(X, thetahat, rr = function(X, theta){exp(theta*X)}, cft) #Example 2: Multivariate case #-------------------------------------------- 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) 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.conditional.variance.linear(X, thetahat, rr, cft) ```