DAG
- class formative.DAG
A directed acyclic graph representing causal assumptions. This should be your starting point for using formative, before fitting any estimators on your data.
Build the graph by calling
assume().causes()for each causal relationship you believe holds. Include latent variables freely — if a node is not in your data atfit()time, the estimator treats it as unobserved.Example:
dag = DAG() dag.assume("ability").causes("education", "income") dag.assume("education").causes("income")
- assume(node)
Name a node and return it so you can assert what it causes:
dag.assume("ability").causes("education")
- Parameters:
node (
str)- Return type:
- property nodes: set[str]
All nodes in the graph.
- property edges: list[tuple[str, str]]
All directed edges as (cause, effect) pairs.
- parents(node)
Direct causes of node.
- Parameters:
node (
str)- Return type:
set[str]
- children(node)
Direct effects of node.
- Parameters:
node (
str)- Return type:
set[str]
- ancestors(node)
All nodes with a directed path leading to node.
- Parameters:
node (
str)- Return type:
set[str]
- descendants(node)
All nodes reachable from node via directed paths.
- Parameters:
node (
str)- Return type:
set[str]
- __repr__()
Return repr(self).
- Return type:
str