Description Usage Arguments Author(s) See Also Examples
View source: R/pif_variance_linear.R
Function that calculates approximate variance of the potential
impact fraction pif
(linearization).
1 2 3 4 |
X |
Random sample ( |
thetahat |
Estimator ( |
rr |
**Optional** |
thetavar |
Estimator of variance of |
cft |
Function |
weights |
Normalized survey |
check_thetas |
Checks that theta parameters are correctly inputed |
check_cft |
Check if counterfactual function |
check_exposure |
Check that exposure |
nsim |
Number of simulations for estimation of variance |
is_paf |
Boolean to force paf evaluation. |
Rodrigo Zepeda-Tello rzepeda17@gmail.com
Dalia Camacho-Garc<c3><ad>a-Forment<c3><ad> daliaf172@gmail.com
pif.variance.approximate.linear
for pif
variance and pif.confidence
for confidence intervals of
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 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.