Learn R Programming

⚠️There's a newer version (1.0.0) of this package.Take me there.

causaloptim: An Interface to Specify Causal Graphs and Compute Bounds on Causal Effects

When causal quantities are not identifiable from the observed data, it still may be possible to bound these quantities using the observed data. We outline a class of problems for which the derivation of tight bounds is always a linear programming problem and can therefore, at least theoretically, be solved using a symbolic linear optimizer. We provide a user friendly graphical interface for setting up such problems via DAGs, which only allow for problems within this class to be depicted. The user can then define linear constraints to further refine their assumptions to meet their specific problem, and then specify a causal query using a text interface. The program converts this user defined DAG, query, and constraints, and returns tight bounds. The bounds can be converted to R functions to evaluate them for specific datasets, and to latex code for publication.

Development status

This package is in stable development. The interface is unlikely to have major changes at this time. New features may be added over time.

Installation

install.packages("causaloptim")
# or
remotes::install_github("sachsmc/causaloptim")

Or use the web application: https://sachsmc.shinyapps.io/causaloptimweb/

Usage

Launch the shiny app to get started, results are saved in the results object:

results <- specify_graph()

References

M.C. Sachs, E.E. Gabriel, and A. Sjölander, "Symbolic Computation of Tight Causal Bounds", 2020. Preprint available at https://sachsmc.github.io/causaloptim/articles/CausalBoundsMethods.pdf .

A. Balke and J. Pearl, "Counterfactual Probabilities: Computational Methods,Bounds, and Applications" UCLA Cognitive Systems Laboratory, Technical Report (R-213-B). In R. Lopez de Mantaras and D. Poole (Eds.), Proceedings of the Conference on Uncertainty in Artificial Intelligence (UAI-94), Morgan Kaufmann, San Mateo, CA, 46-54, July 29-31, 1994. https://ftp.cs.ucla.edu/pub/stat_ser/R213-B.pdf .

Copy Link

Version

Install

install.packages('causaloptim')

Monthly Downloads

360

Version

0.9.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Michael Sachs

Last Published

December 10th, 2021

Functions in causaloptim (0.9.1)

opt_effect

Compute a bound on the average causal effect
numberOfValues

Get the number of values of a given variable in the graph
plot_graphres

Plot the analyzed graph object
list_to_path

Recursive function to translate an effect list to a path sequence
plot.linearcausalproblem

Plot the graph from the causal problem
latex_bounds

Latex bounds equations
optimize_effect_2

Run the optimizer
interpret_bounds

Convert bounds string to a function
parse_constraints

Parse text that defines a the constraints
create_R_matrix

Create constraint matrix
parse_effect

Parse text that defines a causal effect
optimize_effect

Run the Balke optimizer
find_cycles

Find cycles in a graph
print.linearcausalproblem

Print the causal problem
expand_cond

Expand potential outcome conditions
reduce.sets

Algebraically reduce sets
shortentxt

Shorten strings to 80 characters wide
symb.subtract

Symbolic subtraction
pastestar

Paste with asterisk sep
update_effect

Update the effect in a linearcausalproblem object
linear_term

Compute the product of a single numeric scalar and a single string
linear_expression

Compute the scalar product of a vector of numbers and a vector of strings
simulate_bounds

Simulate bounds
specify_graph

Shiny interface to specify network structure and compute bounds
print_nvals

Print the number of values of each variable/vertex of the analyzed graph object
constant_term

Compute the scalar product of two numeric vectors of the same length
create_effect_vector

Translate target effect to vector of response variables
create_response_function

Translate regular DAG to response functions
causaloptim-package

An Interface to Specify Causal Graphs and Compute Bounds on Causal Effects
evaluate_objective

Compute the scalar product of a vector of numbers and a vector of both numbers and strings
const.to.sets

Translate lists of constraints to lists of vectors
create_q_matrix

Translate response functions into matrix of counterfactuals
analyze_graph

Analyze the causal graph to determine constraints and objective
btm_var

Recursive function to get the last name in a list