Package 'noncompliance'

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

Help Index


Bounds for the Average Causal Effect (ACE).

Description

The empirical bounds for the Average Causal Effect (ACE), under the assumptions of the Instrumental Variable (IV) model.

Usage

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)

Arguments

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.

Value

The empirical bounds for the ACE.

References

Richardson, T. S.; Robins, J. M. (2014). ACE Bounds; SEMs with Equilibrium Conditions. Statist. Sci. 29, no. 3, 363-366..

Examples

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))

Posterior bounds for the Average Causal Effect (ACE).

Description

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.

Usage

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)

Arguments

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.

Value

A data frame with the posterior bounds for the ACE, based only on sampled distributions (from the posterior) that satisfied the IV inequalites.

References

Richardson, T. S., Evans, R. J., & Robins, J. M. (2011). Transparent parameterizations of models for potential outcomes. Bayesian Statistics, 9, 569-610.

Examples

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)

"Triangle" plot of the posterior bounds for the Average Causal Effect (ACE).

Description

Plot of the posterior upper bound for the Average Causal Effect (ACE) against the corresponding lower bound.

Usage

ACE_bounds_triangle.plot(bounds, title.txt)

Arguments

bounds

Posterior bounds from the ACE_bounds_posterior function.

title.txt

Title for the plot.

Value

A "triangle" plot.

Examples

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 column totals for Compliers and Never Takers under the sharp null for Compliers.

Description

Finds all compatible column totals for Compliers and Never Takers under the sharp null for Compliers, based on an observed dataset.

Usage

AllColTotalsH0_CONT(n_y0x0z0.H0, n_y1x0z0.H0, n_y0x0z1.H0, n_y1x0z1.H0,
  n_y0x1z1.H0, n_y1x1z1.H0)

Arguments

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.

Value

A data.table with all possible combinations of the column totals for Compliers and Never Takers under the sharp null for Compliers.

Examples

AllColTotalsH0_CONT(158, 14, 52, 12, 23, 78)

Finite population sample space given an observed dataset.

Description

Sample space of all possibly observable datasets given an observed dataset, assuming only Compliers and Never Takers in the population.

Usage

AllPossiblyObsH0_CONT(n_y0x0z0, n_y1x0z0, n_y0x0z1, n_y1x0z1, n_y0x1z1,
  n_y1x1z1, findGLR = FALSE)

Arguments

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.

Value

All possibly observable datasets in a data.table format.

Examples

AllPossiblyObsH0_CONT(16, 1, 5, 1, 2, 8)
AllPossiblyObsH0_CONT(16, 1, 5, 1, 2, 8, findGLR=TRUE)

Bounds for the Average Controlled Direct Effect (ACDE).

Description

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).

Usage

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)

Arguments

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).

Value

The empirical bounds for the ACDE among Always Takers and Never Takers, or the empirical IV inequalities.

References

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.

Examples

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 of the Instrumental Variable (IV) inequalities.

Description

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.

Usage

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)

Arguments

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.

Value

A list of all the IV inequalities or a check of whether all the inequalities have been satisfied empirically.

References

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.

Examples

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 using the data.table package.

Description

Expand.grid (expand.grid) using the data.table package, with up to 4 supplied vectors.

Usage

expand.grid.DT(seq1, seq2, seq3 = NA, seq4 = NA, col.names = NA)

Arguments

seq1

Vector of values.

seq2

Vector of values.

seq3

Vector of values.

seq4

Vector of values.

col.names

Names of columns.

Value

A data.table with all possible combinations (Cartesian product) of the elements in the input vector sequences.

Examples

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)

Maximum Likelihood Estimate under the sharp null for Compliers.

Description

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.

Usage

FindMLE_CONT_H0_hypergeoR(n_y0x0z0, n_y1x0z0, n_y0x0z1, n_y1x0z1, n_y0x1z1,
  n_y1x1z1)

Arguments

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.

Value

The maximum likelihood under the sharp null for Compliers, and the corresponding (possibly non-unique) 2 by 4 contingency table.

Examples

FindMLE_CONT_H0_hypergeoR(158, 14, 52, 12, 23, 78)

Maximum Likelihood Estimate without assuming the sharp null for Compliers.

Description

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.

Usage

FindMLE_CONT_H1_hypergeoR(n_y0x0z0, n_y1x0z0, n_y0x0z1, n_y1x0z1, n_y0x1z1,
  n_y1x1z1)

Arguments

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.

Value

The maximum likelihood, and the corresponding (possibly non-unique) 2 by 4 contingency table.

Examples

FindMLE_CONT_H1_hypergeoR(158, 14, 52, 12, 23, 78)

Exact finite population p-values under the sharp null for Compliers.

Description

Find the exact population-specific p-values under the sharp null for Compliers, for each compatible population with only Compliers and Never Takers.

Usage

Get_pvalues_CONT(obs_y0x0z0, obs_y1x0z0, obs_y0x0z1, obs_y1x0z1, obs_y0x1z1,
  obs_y1x1z1, useGLR = FALSE, justexactp = TRUE, maxonly = TRUE)

Arguments

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.

Value

Exact population-specific p-value(s) for a given observed dataset.

References

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]

Examples

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)