Learn R Programming

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

Sachs, M. C., Jonzon, G., Sjölander, A., & Gabriel, E. E. (2023). A general method for deriving tight symbolic bounds on causal effects. Journal of Computational and Graphical Statistics, 32(2), 567-576. https://www.tandfonline.com/doi/full/10.1080/10618600.2022.2071905/

Jonzon, G., Sachs, M. C., & Gabriel, E. E. (2023). Accessible Computation of Tight Symbolic Bounds on Causal Effects using an Intuitive Graphical Interface. R Journal, 15(4). https://journal.r-project.org/articles/RJ-2023-083/

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

1.0.0

License

MIT + file LICENSE

Maintainer

Michael Sachs

Last Published

October 17th, 2024

Functions in causaloptim (1.0.0)

opt_effect

Compute a bound on the average causal effect
optimize_effect_2

Run the optimizer to obtain symbolic bounds
print.causalmodel

Print relevant information about the causal model
print.linearcausalproblem

Print the causal problem
rdirichlet

Sample from a Dirichlet distribution
querycheck

Check conditions on query
interpret_bounds

Convert bounds string to a function
update_effect

Update the effect in a linearcausalproblem object
specify_graph

Shiny interface to specify network structure and compute bounds
plot.linearcausalproblem

Plot the graph from the causal problem with a legend describing attributes
plot_graphres

Plot the analyzed graph object
simulate_bounds

Simulate bounds
sample_distribution

Sample a distribution of observable probabilities that satisfy the causal model
parse_effect

Parse text that defines a causal effect
parse_constraints

Parse text that defines a the constraints
check_constraints_violated

Check whether any of the observable constraints implied by the causal model are violated for a given distribution of observables
check_parents

Check for paths from from to to
create_causalmodel

Create a structural causal model from a graph or a set of response functions
create_effect_vector

Translate target effect to vector of response variables
btm_var

Recursive function to get the last name in a list
check_linear_objective

Check linearity of objective function implied by a causal model and effect
analyze_graph

Analyze the causal graph and effect to determine constraints and objective
constraintscheck

Check constraints
causaloptim-package

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

Check conditions on causal problem
initialize_graph

Initialize an igraph object for use with causaloptim
create_linearcausalproblem

Create linear causal problem from causal model and effect
find_all_paths

Find all paths in a causal model
latex_bounds

Latex bounds equations
create_response_function

Translate regular DAG to response functions
graphrescheck

Check conditions on digraph
create_q_matrix

Translate response functions into matrix of counterfactuals
get_default_effect

Define default effect for a given graph
list_to_path

Recursive function to translate an effect list to a path sequence