Title: | Causal Inference in the Presence of Treatment Noncompliance Under the Binary Instrumental Variable Model |
---|---|
Description: | A finite-population significance test of the 'sharp' causal null hypothesis that treatment exposure X has no effect on final outcome Y, within the principal stratum of Compliers. A generalized likelihood ratio test statistic is used, and the resulting p-value is exact. Currently, it is assumed that there are only Compliers and Never Takers in the population. |
Authors: | Wen Wei Loh [aut, cre], Thomas S. Richardson [aut] |
Maintainer: | Wen Wei Loh <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.2.2 |
Built: | 2024-10-31 20:49:08 UTC |
Source: | CRAN |
The empirical bounds for the Average Causal Effect (ACE), under the assumptions of the Instrumental Variable (IV) model.
ACE_bounds(n_y0x0z0, n_y1x0z0 = NA, n_y0x1z0 = NA, n_y1x1z0 = NA, n_y0x0z1 = NA, n_y1x0z1 = NA, n_y0x1z1 = NA, n_y1x1z1 = NA)
ACE_bounds(n_y0x0z0, n_y1x0z0 = NA, n_y0x1z0 = NA, n_y1x1z0 = NA, n_y0x0z1 = NA, n_y1x0z1 = NA, n_y0x1z1 = NA, n_y1x1z1 = NA)
n_y0x0z0 |
Number of individuals with Y=0, X=0, Z=0. Alternatively, a vector with elements (either counts, p(y, x , z) or p(y, x | z)) in the order of the arguments. |
n_y1x0z0 |
Number of individuals with Y=1, X=0, Z=0. |
n_y0x1z0 |
Number of individuals with Y=0, X=1, Z=0. |
n_y1x1z0 |
Number of individuals with Y=1, X=1, Z=0. |
n_y0x0z1 |
Number of individuals with Y=0, X=0, Z=1. |
n_y1x0z1 |
Number of individuals with Y=1, X=0, Z=1. |
n_y0x1z1 |
Number of individuals with Y=0, X=1, Z=1. |
n_y1x1z1 |
Number of individuals with Y=1, X=1, Z=1. |
The empirical bounds for the ACE.
Richardson, T. S.; Robins, J. M. (2014). ACE Bounds; SEMs with Equilibrium Conditions. Statist. Sci. 29, no. 3, 363-366..
ACE_bounds(158, 14, 0, 0, 52, 12, 23, 78) ACE_bounds(c(158, 14, 0, 0, 52, 12, 23, 78)) ACE_bounds(99, 1027, 30, 233, 84, 935, 31, 422) ACE_bounds(c(99, 1027, 30, 233, 84, 935, 31, 422))
ACE_bounds(158, 14, 0, 0, 52, 12, 23, 78) ACE_bounds(c(158, 14, 0, 0, 52, 12, 23, 78)) ACE_bounds(99, 1027, 30, 233, 84, 935, 31, 422) ACE_bounds(c(99, 1027, 30, 233, 84, 935, 31, 422))
The posterior bounds for the Average Causal Effect (ACE) is found based on a transparent reparametrization (see reference below), using a Dirichlet prior. A binary Instrumental Variable (IV) model is assumed here.
ACE_bounds_posterior(n_y0x0z0, n_y1x0z0 = NA, n_y0x1z0 = NA, n_y1x1z0 = NA, n_y0x0z1 = NA, n_y1x0z1 = NA, n_y0x1z1 = NA, n_y1x1z1 = NA, prior, num.sims = 1000)
ACE_bounds_posterior(n_y0x0z0, n_y1x0z0 = NA, n_y0x1z0 = NA, n_y1x1z0 = NA, n_y0x0z1 = NA, n_y1x0z1 = NA, n_y0x1z1 = NA, n_y1x1z1 = NA, prior, num.sims = 1000)
n_y0x0z0 |
Number of individuals with Y=0, X=0, Z=0. Alternatively, a vector with elements in the order of the arguments. |
n_y1x0z0 |
Number of individuals with Y=1, X=0, Z=0. |
n_y0x1z0 |
Number of individuals with Y=0, X=1, Z=0. |
n_y1x1z0 |
Number of individuals with Y=1, X=1, Z=0. |
n_y0x0z1 |
Number of individuals with Y=0, X=0, Z=1. |
n_y1x0z1 |
Number of individuals with Y=1, X=0, Z=1. |
n_y0x1z1 |
Number of individuals with Y=0, X=1, Z=1. |
n_y1x1z1 |
Number of individuals with Y=1, X=1, Z=1. |
prior |
Hyperparameters for the Dirichlet prior for p(y, x | z), in the order of the arguments. |
num.sims |
Number of Monte Carlo draws from the posterior. |
A data frame with the posterior bounds for the ACE, based only on sampled distributions (from the posterior) that satisfied the IV inequalites.
Richardson, T. S., Evans, R. J., & Robins, J. M. (2011). Transparent parameterizations of models for potential outcomes. Bayesian Statistics, 9, 569-610.
ACE_bounds_posterior(158, 14, 0, 0, 52, 12, 23, 78, prior = c( rep(1, 2), rep(0, 2), rep(1, 4))) ACE_bounds_posterior(158, 14, 0, 0, 52, 12, 23, 78, prior = c( rep(1/2, 2), rep(0, 2), rep(1/4, 4))) ## Not run: ace.bnds.lipid <- ACE_bounds_posterior(158, 14, 0, 0, 52, 12, 23, 78, prior = c( rep(1, 2), rep(0, 2), rep(1, 4)), num.sims = 2e4) summary(ace.bnds.lipid) ## End(Not run)
ACE_bounds_posterior(158, 14, 0, 0, 52, 12, 23, 78, prior = c( rep(1, 2), rep(0, 2), rep(1, 4))) ACE_bounds_posterior(158, 14, 0, 0, 52, 12, 23, 78, prior = c( rep(1/2, 2), rep(0, 2), rep(1/4, 4))) ## Not run: ace.bnds.lipid <- ACE_bounds_posterior(158, 14, 0, 0, 52, 12, 23, 78, prior = c( rep(1, 2), rep(0, 2), rep(1, 4)), num.sims = 2e4) summary(ace.bnds.lipid) ## End(Not run)
Plot of the posterior upper bound for the Average Causal Effect (ACE) against the corresponding lower bound.
ACE_bounds_triangle.plot(bounds, title.txt)
ACE_bounds_triangle.plot(bounds, title.txt)
bounds |
Posterior bounds from the ACE_bounds_posterior function. |
title.txt |
Title for the plot. |
A "triangle" plot.
ace.bnds.lipid <- ACE_bounds_posterior(158, 14, 0, 0, 52, 12, 23, 78, prior = c( rep(1, 2), rep(0, 2), rep(1, 4))) ACE_bounds_triangle.plot(ace.bnds.lipid, "Bounds on ACE for Lipid Data") ## Not run: ace.bnds.lipid <- ACE_bounds_posterior(158, 14, 0, 0, 52, 12, 23, 78, prior = c( rep(1, 2), rep(0, 2), rep(1, 4)), num.sims = 2e4) ACE_bounds_triangle.plot(ace.bnds.lipid, "Bounds on ACE for Lipid Data") ## End(Not run)
ace.bnds.lipid <- ACE_bounds_posterior(158, 14, 0, 0, 52, 12, 23, 78, prior = c( rep(1, 2), rep(0, 2), rep(1, 4))) ACE_bounds_triangle.plot(ace.bnds.lipid, "Bounds on ACE for Lipid Data") ## Not run: ace.bnds.lipid <- ACE_bounds_posterior(158, 14, 0, 0, 52, 12, 23, 78, prior = c( rep(1, 2), rep(0, 2), rep(1, 4)), num.sims = 2e4) ACE_bounds_triangle.plot(ace.bnds.lipid, "Bounds on ACE for Lipid Data") ## End(Not run)
Finds all compatible column totals for Compliers and Never Takers under the sharp null for Compliers, based on an observed dataset.
AllColTotalsH0_CONT(n_y0x0z0.H0, n_y1x0z0.H0, n_y0x0z1.H0, n_y1x0z1.H0, n_y0x1z1.H0, n_y1x1z1.H0)
AllColTotalsH0_CONT(n_y0x0z0.H0, n_y1x0z0.H0, n_y0x0z1.H0, n_y1x0z1.H0, n_y0x1z1.H0, n_y1x1z1.H0)
n_y0x0z0.H0 |
Number of individuals with Y=0, X=0, Z=0. |
n_y1x0z0.H0 |
Number of individuals with Y=1, X=0, Z=0. |
n_y0x0z1.H0 |
Number of individuals with Y=0, X=0, Z=1. |
n_y1x0z1.H0 |
Number of individuals with Y=1, X=0, Z=1. |
n_y0x1z1.H0 |
Number of individuals with Y=0, X=1, Z=1. |
n_y1x1z1.H0 |
Number of individuals with Y=1, X=1, Z=1. |
A data.table with all possible combinations of the column totals for Compliers and Never Takers under the sharp null for Compliers.
AllColTotalsH0_CONT(158, 14, 52, 12, 23, 78)
AllColTotalsH0_CONT(158, 14, 52, 12, 23, 78)
Sample space of all possibly observable datasets given an observed dataset, assuming only Compliers and Never Takers in the population.
AllPossiblyObsH0_CONT(n_y0x0z0, n_y1x0z0, n_y0x0z1, n_y1x0z1, n_y0x1z1, n_y1x1z1, findGLR = FALSE)
AllPossiblyObsH0_CONT(n_y0x0z0, n_y1x0z0, n_y0x0z1, n_y1x0z1, n_y0x1z1, n_y1x1z1, findGLR = FALSE)
n_y0x0z0 |
Number of individuals with Y=0, X=0, Z=0. |
n_y1x0z0 |
Number of individuals with Y=1, X=0, Z=0. |
n_y0x0z1 |
Number of individuals with Y=0, X=0, Z=1. |
n_y1x0z1 |
Number of individuals with Y=1, X=0, Z=1. |
n_y0x1z1 |
Number of individuals with Y=0, X=1, Z=1. |
n_y1x1z1 |
Number of individuals with Y=1, X=1, Z=1. |
findGLR |
Whether or not to find the generalized likelihood ratio (GLR) test statistic for each possible observable dataset. |
All possibly observable datasets in a data.table format.
AllPossiblyObsH0_CONT(16, 1, 5, 1, 2, 8) AllPossiblyObsH0_CONT(16, 1, 5, 1, 2, 8, findGLR=TRUE)
AllPossiblyObsH0_CONT(16, 1, 5, 1, 2, 8) AllPossiblyObsH0_CONT(16, 1, 5, 1, 2, 8, findGLR=TRUE)
The empirical bounds for the Average Controlled Direct Effect (ACDE) within the principal strata of Always Takers and Never Takers, under the assumption of monotonicity (no Defiers). These are equivalent to an empirical check of the Instrumental Variable (IV) inequalities (see references below).
Check_ACDE_bounds(n_y0x0z0, n_y1x0z0 = NA, n_y0x1z0 = NA, n_y1x1z0 = NA, n_y0x0z1 = NA, n_y1x0z1 = NA, n_y0x1z1 = NA, n_y1x1z1 = NA, iv.ineqs = FALSE)
Check_ACDE_bounds(n_y0x0z0, n_y1x0z0 = NA, n_y0x1z0 = NA, n_y1x1z0 = NA, n_y0x0z1 = NA, n_y1x0z1 = NA, n_y0x1z1 = NA, n_y1x1z1 = NA, iv.ineqs = FALSE)
n_y0x0z0 |
Number of individuals with Y=0, X=0, Z=0. Alternatively, a vector with elements (either counts, p(y, x , z) or p(y, x | z)) in the order of the arguments. |
n_y1x0z0 |
Number of individuals with Y=1, X=0, Z=0. |
n_y0x1z0 |
Number of individuals with Y=0, X=1, Z=0. |
n_y1x1z0 |
Number of individuals with Y=1, X=1, Z=0. |
n_y0x0z1 |
Number of individuals with Y=0, X=0, Z=1. |
n_y1x0z1 |
Number of individuals with Y=1, X=0, Z=1. |
n_y0x1z1 |
Number of individuals with Y=0, X=1, Z=1. |
n_y1x1z1 |
Number of individuals with Y=1, X=1, Z=1. |
iv.ineqs |
Whether to return the empirical bounds or the IV inequalities (TRUE). |
The empirical bounds for the ACDE among Always Takers and Never Takers, or the empirical IV inequalities.
Richardson, T. S., Evans, R. J., & Robins, J. M. (2011). Transparent parameterizations of models for potential outcomes. Bayesian Statistics, 9, 569-610.
A. Balke and J. Pearl. (1997). Bounds on treatment effects from studies with imperfect compliance. Journal of the American Statistical Association, 1171-1176.
Check_ACDE_bounds(99, 1027, 30, 233, 84, 935, 31, 422) Check_ACDE_bounds(c(99, 1027, 30, 233, 84, 935, 31, 422)) Check_ACDE_bounds(99, 1027, 30, 233, 84, 935, 31, 422, iv.ineqs=TRUE) Check_ACDE_bounds(c(99, 1027, 30, 233, 84, 935, 31, 422), iv.ineqs=TRUE)
Check_ACDE_bounds(99, 1027, 30, 233, 84, 935, 31, 422) Check_ACDE_bounds(c(99, 1027, 30, 233, 84, 935, 31, 422)) Check_ACDE_bounds(99, 1027, 30, 233, 84, 935, 31, 422, iv.ineqs=TRUE) Check_ACDE_bounds(c(99, 1027, 30, 233, 84, 935, 31, 422), iv.ineqs=TRUE)
This checks whether the Instrumental Variable (IV) inequalities for a binary dataset have been satisfied empirically, assuming only Randomization and Exclusion Restriction for the principal strata of Always Takers and Never Takers. Monotonicity (no Defiers) is not assumed here.
Check_IV_ineqs(n_y0x0z0, n_y1x0z0 = NA, n_y0x1z0 = NA, n_y1x1z0 = NA, n_y0x0z1 = NA, n_y1x0z1 = NA, n_y0x1z1 = NA, n_y1x1z1 = NA, verbose = FALSE)
Check_IV_ineqs(n_y0x0z0, n_y1x0z0 = NA, n_y0x1z0 = NA, n_y1x1z0 = NA, n_y0x0z1 = NA, n_y1x0z1 = NA, n_y0x1z1 = NA, n_y1x1z1 = NA, verbose = FALSE)
n_y0x0z0 |
Number of individuals with Y=0, X=0, Z=0. Alternatively, a vector with elements (either counts, p(y, x , z) or p(y, x | z)) in the order of the arguments. |
n_y1x0z0 |
Number of individuals with Y=1, X=0, Z=0. |
n_y0x1z0 |
Number of individuals with Y=0, X=1, Z=0. |
n_y1x1z0 |
Number of individuals with Y=1, X=1, Z=0. |
n_y0x0z1 |
Number of individuals with Y=0, X=0, Z=1. |
n_y1x0z1 |
Number of individuals with Y=1, X=0, Z=1. |
n_y0x1z1 |
Number of individuals with Y=0, X=1, Z=1. |
n_y1x1z1 |
Number of individuals with Y=1, X=1, Z=1. |
verbose |
Whether to return all the IV inequalities (TRUE) or just a check that the inequalities have been satisfied empirically. |
A list of all the IV inequalities or a check of whether all the inequalities have been satisfied empirically.
A. Balke and J. Pearl. (1997). Bounds on treatment effects from studies with imperfect compliance. Journal of the American Statistical Association, 1171-1176.,
B. Bonet. (2001). Instrumentality tests revisited. In Proceedings of the Seventeenth Conference on Uncertainty in Artificial Intelligence, 48-55.
Check_IV_ineqs(158, 14, 0, 0, 52, 12, 23, 78) Check_IV_ineqs(c(158, 14, 0, 0, 52, 12, 23, 78)) Check_IV_ineqs(158, 14, 0, 0, 52, 12, 23, 78, TRUE) Check_IV_ineqs(99, 1027, 30, 233, 84, 935, 31, 422) Check_IV_ineqs(c(99, 1027, 30, 233, 84, 935, 31, 422)) Check_IV_ineqs(99, 1027, 30, 233, 84, 935, 31, 422, TRUE)
Check_IV_ineqs(158, 14, 0, 0, 52, 12, 23, 78) Check_IV_ineqs(c(158, 14, 0, 0, 52, 12, 23, 78)) Check_IV_ineqs(158, 14, 0, 0, 52, 12, 23, 78, TRUE) Check_IV_ineqs(99, 1027, 30, 233, 84, 935, 31, 422) Check_IV_ineqs(c(99, 1027, 30, 233, 84, 935, 31, 422)) Check_IV_ineqs(99, 1027, 30, 233, 84, 935, 31, 422, TRUE)
Expand.grid (expand.grid
) using the
data.table
package,
with up to 4 supplied vectors.
expand.grid.DT(seq1, seq2, seq3 = NA, seq4 = NA, col.names = NA)
expand.grid.DT(seq1, seq2, seq3 = NA, seq4 = NA, col.names = NA)
seq1 |
Vector of values. |
seq2 |
Vector of values. |
seq3 |
Vector of values. |
seq4 |
Vector of values. |
col.names |
Names of columns. |
A data.table with all possible combinations (Cartesian product) of the elements in the input vector sequences.
expand.grid.DT(1:10, 100:110) expand.grid.DT(1:10, 100:110, col.names=c("A", "B")) expand.grid.DT(1:10, 100:110, 11:13, 1:2)
expand.grid.DT(1:10, 100:110) expand.grid.DT(1:10, 100:110, col.names=c("A", "B")) expand.grid.DT(1:10, 100:110, 11:13, 1:2)
Find the maximum likelihood estimate of the 2 by 4 contingency table assuming only Compliers and Never Takers in the population, under the sharp null for Compliers and with the multivariate hypergeometric sampling distribution.
FindMLE_CONT_H0_hypergeoR(n_y0x0z0, n_y1x0z0, n_y0x0z1, n_y1x0z1, n_y0x1z1, n_y1x1z1)
FindMLE_CONT_H0_hypergeoR(n_y0x0z0, n_y1x0z0, n_y0x0z1, n_y1x0z1, n_y0x1z1, n_y1x1z1)
n_y0x0z0 |
Number of individuals with Y=0, X=0, Z=0. |
n_y1x0z0 |
Number of individuals with Y=1, X=0, Z=0. |
n_y0x0z1 |
Number of individuals with Y=0, X=0, Z=1. |
n_y1x0z1 |
Number of individuals with Y=1, X=0, Z=1. |
n_y0x1z1 |
Number of individuals with Y=0, X=1, Z=1. |
n_y1x1z1 |
Number of individuals with Y=1, X=1, Z=1. |
The maximum likelihood under the sharp null for Compliers, and the corresponding (possibly non-unique) 2 by 4 contingency table.
FindMLE_CONT_H0_hypergeoR(158, 14, 52, 12, 23, 78)
FindMLE_CONT_H0_hypergeoR(158, 14, 52, 12, 23, 78)
Find the maximum likelihood estimate of the 2 by 4 contingency table assuming only Compliers and Never Takers in the population, with the multivariate hypergeometric sampling distribution.
FindMLE_CONT_H1_hypergeoR(n_y0x0z0, n_y1x0z0, n_y0x0z1, n_y1x0z1, n_y0x1z1, n_y1x1z1)
FindMLE_CONT_H1_hypergeoR(n_y0x0z0, n_y1x0z0, n_y0x0z1, n_y1x0z1, n_y0x1z1, n_y1x1z1)
n_y0x0z0 |
Number of individuals with Y=0, X=0, Z=0. |
n_y1x0z0 |
Number of individuals with Y=1, X=0, Z=0. |
n_y0x0z1 |
Number of individuals with Y=0, X=0, Z=1. |
n_y1x0z1 |
Number of individuals with Y=1, X=0, Z=1. |
n_y0x1z1 |
Number of individuals with Y=0, X=1, Z=1. |
n_y1x1z1 |
Number of individuals with Y=1, X=1, Z=1. |
The maximum likelihood, and the corresponding (possibly non-unique) 2 by 4 contingency table.
FindMLE_CONT_H1_hypergeoR(158, 14, 52, 12, 23, 78)
FindMLE_CONT_H1_hypergeoR(158, 14, 52, 12, 23, 78)
Find the exact population-specific p-values under the sharp null for Compliers, for each compatible population with only Compliers and Never Takers.
Get_pvalues_CONT(obs_y0x0z0, obs_y1x0z0, obs_y0x0z1, obs_y1x0z1, obs_y0x1z1, obs_y1x1z1, useGLR = FALSE, justexactp = TRUE, maxonly = TRUE)
Get_pvalues_CONT(obs_y0x0z0, obs_y1x0z0, obs_y0x0z1, obs_y1x0z1, obs_y0x1z1, obs_y1x1z1, useGLR = FALSE, justexactp = TRUE, maxonly = TRUE)
obs_y0x0z0 |
Number of observed individuals with Y=0, X=0, Z=0. |
obs_y1x0z0 |
Number of observed individuals with Y=1, X=0, Z=0. |
obs_y0x0z1 |
Number of observed individuals with Y=0, X=0, Z=1. |
obs_y1x0z1 |
Number of observed individuals with Y=1, X=0, Z=1. |
obs_y0x1z1 |
Number of observed individuals with Y=0, X=1, Z=1. |
obs_y1x1z1 |
Number of observed individuals with Y=1, X=1, Z=1. |
useGLR |
Whether or not to use the generalized likelihood ratio (GLR) test statistic. |
justexactp |
Just find the total probability of the critical region for each population, or the total probabilty of the sampling distribution (which should be 1). |
maxonly |
Whether to return only the maximum population-specific p-value, or all the population-specific p-values. |
Exact population-specific p-value(s) for a given observed dataset.
Loh, W. W., & Richardson, T. S. (2015). A Finite Population Likelihood Ratio Test of the Sharp Null Hypothesis for Compliers. In Thirty-First Conference on Uncertainty in Artificial Intelligence. [paper]
Get_pvalues_CONT(16, 1, 5, 1, 2, 8) Get_pvalues_CONT(16, 1, 5, 1, 2, 8, TRUE, FALSE) Get_pvalues_CONT(16, 1, 5, 1, 2, 8, TRUE, FALSE, FALSE) Get_pvalues_CONT(158, 14, 52, 12, 23, 78)
Get_pvalues_CONT(16, 1, 5, 1, 2, 8) Get_pvalues_CONT(16, 1, 5, 1, 2, 8, TRUE, FALSE) Get_pvalues_CONT(16, 1, 5, 1, 2, 8, TRUE, FALSE, FALSE) Get_pvalues_CONT(158, 14, 52, 12, 23, 78)