Formative
quantitative reasoning made simple (but not easy)
$
pip install formative-dsexample.py
from formative.causal import DAG, OLSObservationalfrom formative.game import minimax, maximax, maximin # ---- Causal estimation (with heterogeneous effects) ---- dag = DAG()dag.assume("ability").causes("education", "income")dag.assume("segment").causes("income")dag.assume("education").causes("income") result = OLSObservational( dag, treatment="education", outcome="income", effect_modifier="segment", # effect estimated per segment).fit(df)print(result.summary()) # ---- Refutation ---- print(result.refute(df).summary()) # ---- Decisions ---- decision = result.decide(cost=2.5, benefit=1.0)print(decision) for level, d in result.decide_by_group(cost=2.5, benefit=1.0).items(): print(level, "→", d.optimal) # different segments # ---- Decisions via game theory ---- outcomes = decision.to_outcomes()print(minimax(outcomes).solve()) # pessimistic choiceprint(maximax(outcomes).solve()) # high risk, high rewardprint(maximin(outcomes).solve()) # best worst-caseFind the right method
Answer a few questions to find the right approach for measuring cause and effect in your situation.
Methods
1
Can you decide who receives the intervention?
Do you have the ability to choose or control who gets the treatment?