dowhy icon indicating copy to clipboard operation
dowhy copied to clipboard

Placebo refuter with multiple treatments

Open JasonTam opened this issue 4 years ago • 2 comments

Hi, I'm wondering if it makes sense to replace individual treatments with a placebo variable when there are multiple treatments. I've tried estimating the effect of toggling a single treatment on and then running the placebo refuter as usual:

import dowhy
from dowhy import CausalModel
import dowhy.datasets

n_treatments = 3
data = dowhy.datasets.linear_dataset(
    num_samples=10000, beta=10, 
    num_common_causes=0,
    num_instruments=0, 
    num_effect_modifiers=0,
    num_treatments=n_treatments,
    treatment_is_binary=True,
    outcome_is_binary=True,
    num_discrete_common_causes=0,
    num_discrete_effect_modifiers=0,
    one_hot_encode=False)

model = CausalModel(
    data=data["df"],
    treatment=data["treatment_name"], 
    outcome=data["outcome_name"],
    graph=data["gml_graph"])

identified_estimand = model.identify_effect(proceed_when_unidentifiable=True)

estimate_001 = model.estimate_effect(
    identified_estimand,
    method_name="backdoor.linear_regression",
    control_value=[0] * n_treatments,
    treatment_value=[0, 0, 1],
    method_params={'need_conditional_estimates': False})

res_placebo = model.refute_estimate(
    identified_estimand, estimate_001, 
    method_name="placebo_treatment_refuter", 
    placebo_type="permute")

But this gives:

~/anaconda3/lib/python3.8/site-packages/pandas/core/internals/blocks.py in __init__(self, values, placement, ndim)
    140 
    141         if self._validate_ndim and self.ndim and len(self.mgr_locs) != len(self.values):
--> 142             raise ValueError(
    143                 f"Wrong number of items passed {len(self.values)}, "
    144                 f"placement implies {len(self.mgr_locs)}"

ValueError: Wrong number of items passed 3, placement implies 1

Not sure if I'm running into a limitation of the placebo refuter, or if this is just logically incorrect.

Appreciate any help, and thanks for such a great library!

JasonTam avatar Mar 18 '21 21:03 JasonTam

@JasonTam this is probably a bug. For multi-dimensional treatment, there should be an option for the user to choose which treatment(s) they want to convert to placebo. This will be fixed in the next release. I will post a reply here when the fix is pushed to master.

amit-sharma avatar Mar 21 '21 15:03 amit-sharma

@amit-sharma Any update on this?

shivin9 avatar Jun 11 '23 05:06 shivin9