Title: | Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions |
---|---|
Description: | Implementation of the nonparametric bounds for the average causal effect under an instrumental variable model by Balke and Pearl (Bounds on Treatment Effects from Studies with Imperfect Compliance, JASA, 1997, 92, 439, 1171-1176, <doi:10.2307/2965583>). The package can calculate bounds for a binary outcome, a binary treatment/phenotype, and an instrument with either 2 or 3 categories. The package implements bounds for situations where these 3 variables are measured in the same dataset (trivariate data) or where the outcome and instrument are measured in one study and the treatment/phenotype and instrument are measured in another study (bivariate data). |
Authors: | Tom Palmer [aut, cre] , Roland Ramsahai [aut] , Vanessa Didelez [aut] , Nuala Sheehan [aut] |
Maintainer: | Tom Palmer <[email protected]> |
License: | GPL-3 |
Version: | 0.1.6.9000 |
Built: | 2024-11-01 11:19:43 UTC |
Source: | https://github.com/remlapmot/bpbounds |
Nonparametric Bounds for the Average Causal Effect due to Balke and Pearl.
bpbounds(p, t = NULL, fmt = "trivariate")
bpbounds(p, t = NULL, fmt = "trivariate")
p |
Object of class "table" containing either cell counts or conditional probabilities. For trivariate data these are for the phenotype/treatment-outcome association given Z, i.e. P(X, Y | Z). Cell counts could be generated from If you only know the conditional probabilities you can enter these, e.g. for the Balke and Pearl Vitamin A example: cp <- c(.0064, 0, .9936, 0, .0028, .001, .1972, .799) tabp <- as.table(array( cp, dim = c(2, 2, 2), dimnames = list( x = c(0, 1), y = c(0, 1), z = c(0, 1) ) )) And then call For bivariate data this object contains cell conditional probabilities for the outcome-instrument (Y|Z) association. |
t |
Specified for bivariate data. Object with treatment/phenotype-instrument cell counts or conditional probabilities, i.e. (X|Z). |
fmt |
A character string which sould be either "bivariate" (i.e. X, Z in one dataset and Y, Z in another dataset) or "trivariate" (X, Y, Z in the same dataset). |
List with the following elements:
whether the data is bivariate or trivariate
2 or 3, the no. instrument categories
Logical, indicating whether the IV inquality is satisfied
Lower bound of ACE
Upper bound of ACE
Vector of lower bound probabilities
Vector of upper bound probabilities
Lower bound of P(Y=1|do(X=1))
Upper bound of P(Y=1|do(X=1))
Lower bound of P(Y=1|do(X=0))
Upper bound of P(Y=1|do(X=0))
Vector of probabilities for lower bound of P(Y=1|do(X=1))
Vector of probabilities for upper bound of P(Y=1|do(X=1))
Vector of probabilities for lower bound of P(Y=1|do(X=0))
Vector of probabilities for upper bound of P(Y=1|do(X=0))
Lower bound of CRR
Upper bound of CRR
Logical, indicating whether the monoticity inequality is satisfied
Lower bound of ACE assuming monotonicity
Upper bound of ACE assuming monotonicity
Vector of probabilities for lower bound of ACE assuming monotonicity
Vector of probabilities for upper bound of ACE assuming monotonicity
Lower bound of P(Y=1|do(X=1)) assuming monotonicity
Upper bound of P(Y=1|do(X=1)) assuming monotonicity
Lower bound of P(Y=1|do(X=0)) assuming monotonicity
Upper bound of P(Y=1|do(X=0)) assuming monotonicity
Vector for corresponding bound above
Vector for corresponding bound above
Vector for corresponding bound above
Vector for corresponding bound above
Lower bound of CRR assuming monotonicity
Upper bound of CRR assuming monotonicity
# Vitamin A example, using cell counts require(tidyr) require(bpbounds) tab1dat <- data.frame( z = c(0, 0, 1, 1, 1, 1, 0, 0), x = c(0, 0, 0, 0, 1, 1, 1, 1), y = c(0, 1, 0, 1, 0, 1, 0, 1), freq = c(74, 11514, 34, 2385, 12, 9663, 0, 0) ) tab1inddat <- uncount(tab1dat, freq) xt <- xtabs(~ x + y + z, data = tab1inddat) p <- prop.table(xt, margin = 3) bpres <- bpbounds(p) sbpres <- summary(bpres) print(sbpres) # Vitamin A example, using conditional probabilities require(bpbounds) cp = c(.0064, 0, .9936, 0, .0028, .001, .1972, .799) tabp = as.table(array( cp, dim = c(2, 2, 2), dimnames = list( x = c(0, 1), y = c(0, 1), z = c(0, 1) ) )) bpbounds(tabp)
# Vitamin A example, using cell counts require(tidyr) require(bpbounds) tab1dat <- data.frame( z = c(0, 0, 1, 1, 1, 1, 0, 0), x = c(0, 0, 0, 0, 1, 1, 1, 1), y = c(0, 1, 0, 1, 0, 1, 0, 1), freq = c(74, 11514, 34, 2385, 12, 9663, 0, 0) ) tab1inddat <- uncount(tab1dat, freq) xt <- xtabs(~ x + y + z, data = tab1inddat) p <- prop.table(xt, margin = 3) bpres <- bpbounds(p) sbpres <- summary(bpres) print(sbpres) # Vitamin A example, using conditional probabilities require(bpbounds) cp = c(.0064, 0, .9936, 0, .0028, .001, .1972, .799) tabp = as.table(array( cp, dim = c(2, 2, 2), dimnames = list( x = c(0, 1), y = c(0, 1), z = c(0, 1) ) )) bpbounds(tabp)
Run Shiny App demonstrating the package
runExample(...)
runExample(...)
... |
passed to |
if (interactive() && requireNamespace("shiny", quietly = TRUE)) { bpbounds::runExample() }
if (interactive() && requireNamespace("shiny", quietly = TRUE)) { bpbounds::runExample() }