EconML
EconML copied to clipboard
what will the outcome Y (continuous) in group G be if I DECREASE the treatment T (continuous) variable by x%?
Hi team. Thanks for this amazing framework!
Going through many notebooks, and presentations, and sneaking into the issues, I couldn't find a proper "intervention estimation" workflow. My setting is as follows:
Question: "what will the outcome Y (continuous) in group G be if I DECREASE the treatment T (continuous) variable by x%?
Y = continuous [0-20000] T = continupus [0-400] X = matrix of 16 confounders G = 165 Years = 15 years
I have 16 X confounders affecting both Y and T.
So how would I frame it in dowhy/EconmL context so that I get the heterogeneous effect of a treatment (% decreasing in T) that didn't actually happen? It is like my "ground truth" is what happened in the historical data, but I would like to see if, for the next year, a change in X will affect Y.
EconML's CATE estimators are based around telling you how an outcome (Y) will change given some change in the treatment (T), conditional on some confounders (X). If you have historical data, then one way of generating a counterfactual prediction would be to add this effect to the historical output (e.g. something like counter_factual_output = historical_output + est.effect(X=features, T0=original_treatment, T1=new_treatment)
).
Does that answer your question?
@kbattocchi Thank you for the quick reply.
"If you have historical data, then one way of generating a counterfactual prediction would be to add this effect to the historical output "
f I get it correctly: Y is my historical output (aka historica_output) and T is my historical input (aka T0-original treatment). Xs are also historical confounders (X features). However, my T1=newtreatment is actually an applied decrease of X% to T0=original treatment. In this case, the formula you suggested would be:
counter_factual_output = historical_output - est.effect(X=features, T0=original_treatment, T1=T0*X% decrease)).
How would I recover the counter_factual_output BY GROUP and use the model to make "predictions of impacts at A% B%, C% and N% decrease in T?
This part is not quite right:
counter_factual_output = historical_output - est.effect(X=features, T0=original_treatment, T1=T0*X% decrease)).
because you still ought to add the effect, not subtract it (but if decreasing the treatment reduces output the effect will be negative, so adding it will reduce the total as expected).
I'm not sure I completely understand your question about groups; the result stored in counter_factual_output will be an array with rows that correspond to the rows of the inputs, so you can use numpy indexing operations with a mask defined by group to get only the results from a single group and then aggregate those however you'd like (perhaps turn them into percentage change based on the original outputs and then take the geometric mean to get an "overall percentage change").
Most EconML estimators are linear, so est.effect(X, T0, T0*0.8)
will probably just be est.effect(X, T0, T0*0.9) * 2
(and alternatively you could use est.const_marginal_effect(X)
to get the marginal effect in that case and multiply it by -T0*0.1
and -T0*0.2
to get these same treatment effects); I'd be wary of extrapolating these estimates too far since roughly linear effects might be reasonable at small scale even if they don't hold for larger changes, and also because the data you are fitting the estimator on may not have sufficient data for unlikely treatment ranges to learn an accurate model for such large changes in any case.
Got it. My setup is fully observational and all the variables are at the country level. It is panel data. The DynamicDML may fit here as well.