Causal inference in python - where to start? Point 1: I'm not sure if this question could be asked here, as it is may not seem to be about the "science" itself at the first glance! At the second glance though, I think in practice several newbies would face this question and it is a public benefit to have it for reference of people
Point 2: If the community think that this is an inappropriate place for this question, I would delete the whole question when I get an answer. Otherwise, I would edit the question and remove these two points and let the question be here for the reference of others.
So I'm new to the world of causal inference. I am learning some elementary concepts such as DAG, matching on covariates/propensity score, etc. The problem is that I don't know where to start in terms of available packages in python? I have found several packages DoWhy, EconML, Causalib, CausalML, CausalNex, etc... .
The point is that I don't know where to start for these simple tasks such as building a DAG, or matching in python? Does anyone know about a "meta-reference" to know how to work thorough among these libraries?
 A: Here are a few good websites/books that I am fond of that use DAGs, and have code examples in R, Python, and Stata on github or packaged up.

*

*Causal Inference: The
Mixtape and its
github


*Data Analysis for Business, Economics, and
Policy and its
github.


*The Effect, with examples in packages:

*

*install.packages('causaldata') in R

*ssc install causaldata in Stata

*pip install causaldata in Python.



*Using Python for Introductory Econometrics by Florian Heiss and Daniel Brunner.
This is not exactly the cutting-edge stuff, but the foundation you need to get started.
I am an economist at a tech company who uses and teaches these methods.
A: Not exactly a meta-reference, but I have been working on a causal inference library, zEpid. It is mainly from the epidemiology perspective, since that is what my training is in. (I also disagree that causal inference is "mostly connected to econometrics").
My goal was to develop a cohesive library of the various estimators common in epidemiology, as well as other common tools. So you can build a DAG, estimate causal effects for time-fixed exposures, there is some support for time-varying exposures, and other more general functionalities. I also have tried to provide detailed tutorials that demonstrate the code and motivate the ideas behind the approaches. Most of them are located here.
As Dimitriy said, there are several good books that have code available. Another book to consider is What If. I also demonstrate the examples from that book here (there is also code linked on their site).
I used to keep more up-to-date with the other libraries, but have fallen behind. I think a resource that compares some of the available libraries, but I am unaware of such a thing. One major difference between the libraries is the field they come from. For example, I don't have any support for IV analyses, but econ causal inference libraries have much more support. There is also different value judgements from each of the fields about what quantities are important and what methods should be considered. A good starting place would be the field your background is closest to.
A: Take a look at https://github.com/gmgeorg/pypsps for a ready-to-go TensorFlow keras implementation for causal inference using computational graphs.  See README and notebooks for code examples and case studies.
For example here is an end-to-end example of simulating data, building a model, training & evaluating the model, and -- last but not least -- estimate the ATE & unit level treatment effects.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

from pypsps.keras import models
from pypsps import datasets, inference, utils

np.random.seed(10)
ks_data = datasets.KangSchafer(n_samples=1000, true_ate=20).run()
tf.random.set_seed(10)
model = models.build_toy_model(
    n_states=4, n_features=ks_data.n_features, compile=True, alpha=10.
)
inputs, outputs = ks_data.to_keras_inputs_outputs()
history = model.fit(inputs,
                    outputs,
                    epochs=250,
                    batch_size=64,
                    verbose=2,
                    validation_split=0.2,
                    callbacks=models.recommended_callbacks(),
                    )
preds = model.predict(inputs)
outcome_pred, scale, propensity_score, weights = utils.split_y_pred(preds)

pred_ate = inference.predict_ate(model, ks_data.features)
print("ATE\n\t true: %.1f \n\tnaive: %.1f \n\t PSPS: %.1f" % (
    ks_data.true_ate, ks_data.naive_ate(), pred_ate)
    )
pd.DataFrame(history.history)[["loss", "val_loss"]].plot(logy=True); plt.grid()

ATE
     true: 20.0 
    naive: -1.3 
     PSPS: 17.3


A: From what I see causal inference (CI) is mostly connected to econometrics, and vastly to its most basic concepts. Also it is mostly academic domain, since the companies are usually not interested in any inference at all.
The tools to use in applied CI are often limited to the basic regressions, panels, IV. The DAG's, understanding endogeneity and some other CI concepts complement those tools. There are some sophisticated tricks to help with the identification of the parameters, but the tools themselves are mostly very basic.
The statsmodels package with pandas and something to make charts, like plotly may be more than enough to start and finish your PhD in applied CI.
However, it really depends on what you aim for. CI is quite a big field, and there are many sophisticated areas within it. But from my perspective - they are not the core.
