jtextor / dagitty

Graphical analysis of structural causal models / graphical causal models.
GNU General Public License v2.0
282 stars 46 forks source link

adjustmentSets function doesn't work for some DAGs #22

Closed IyarLin closed 5 years ago

IyarLin commented 5 years ago

Hi, I'm using the development version: '0.2.3' I've built the following DAG:

g <- dagitty( "dag {
churn [outcome]
cong [exposure]
cong -> CX [beta = -0.3]
CX -> churn [beta = -0.5]
comp -> cong [beta = -0.4]
comp -> churn [beta = 0.9]
cong -> brand [beta = -0.8]
brand -> comp [beta = 0.7]
demo -> comp [beta = 0.4]
demo -> churn [beta = -0.7]
}" )

I know that in order to estimate the causal effect of cong on churn I need to condition on {comp, demo}. I've verified that in simulation as well.

Running the following command:

print(adjustmentSets(g))

Yield an empty set.

I've tried removing the betas or move the exposure/outcome enumeration to the function itself to no avail. It seems that only if I reduce the model a bit e.g.:

g <- dagitty( "dag {
churn [outcome]
cong [exposure]
cong -> CX [beta = -0.3]
CX -> churn [beta = -0.5]
comp -> cong [beta = -0.4]
comp -> churn [beta = 0.9]
cong -> brand [beta = -0.8]
}" )

I get the right conditioning set ({comp}) by running print(adjustmentSets(g))

See attached md file too try.docx

jtextor commented 5 years ago

Hi,

Your graph is not a DAG -- it contains a cycle. Adjustment sets are not defined for cyclic models. Accordingly, dagitty returns no adjustment set (this is different from an empy set!)

I believe therefore that dagitty works as expected on this example.

Best regards Johannes

IyarLin commented 5 years ago

Great catch. Thanks!