Description Usage Arguments Author(s) See Also Examples
Function that calculates the conditional variance of the
potential impact fraction pif
(linearization).
1 2 3 |
X |
Random sample ( |
thetahat |
Estimator ( |
rr |
**Optional** |
cft |
Function |
weights |
Survey |
check_cft |
Check if counterfactual function |
is_paf |
Force evaluation of |
Rodrigo Zepeda-Tello rzepeda17@gmail.com
Dalia Camacho-GarcĂa-FormentĂ daliaf172@gmail.com
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.