Identification

Identification algorithms.

Identification

Algorithm

Implementation

ID [shpitser2006]

y0.algorithm.identifiy.id_std

IDC [shpitser2008]

y0.algorithm.identifiy.idc

ID* [shpitser2012]

y0.algorithm.identifiy.id_star

IDC* [shpitser2012]

y0.algorithm.identifiy.idc_star

Cyclic ID [forre2019]

Issue #71

gID [correa2019]

Issue #72

gID* [correa2021]

Issue #121

Data ID [nabi2020]

Issue #73

This table partially draws from [tikka2021], which made a nice review of non-counterfactual identification methods.

Transport

Algorithm

Implementation

Surrogate Outcomes [tikka2018]

y0.algorithm.transport

Transportability [correa2020]

y0.algorithm.transport

Counterfactual Transportability [correa2022]

PR #197

identify_outcomes(graph: NxMixedGraph, treatments: Variable | set[Variable], outcomes: Variable | set[Variable], conditions: None | Variable | set[Variable] = None) Expression | None[source]

Calculate the estimand for the treatment(s)m outcome(s), and optional condition(s).

Parameters:
  • graph – An acyclic directed mixed graph

  • treatments – The node or nodes that are treated

  • outcomes – The node or nodes that are outcomes

  • conditions – Optional condition or condition nodes. If given, uses the IDC algorithm via y0.algorithm.identify.idc(). Otherwise, uses the ID algorithm via y0.algorithm.identify.identify().

Returns:

An expression representing the estimand if the query is identifiable. If the query is not identifiable, returns none.

identify(identification: Identification) Expression[source]

Run the ID algorithm from [shpitser2006].

Parameters:

identification – The identification tuple

Returns:

the expression corresponding to the identification

Raises:

Unidentifiable – If no appropriate identification can be found

See also identify_outcomes() for a more idiomatic way of running the ID algorithm given a graph, treatments, and outcomes.

id_star(graph: NxMixedGraph, event: Dict[Variable, Intervention], *, _number_recursions: int = 0) Expression[source]

Apply the ID* algorithm to the graph from [shpitser2012].

idc(identification: Identification) Expression[source]

Run the IDC algorithm from [shpitser2008].

Parameters:

identification – The identification tuple

Returns:

An expression created by the identify() algorithm after simplifying the original query

Raises “Unidentifiable” if no appropriate identification can be found.

idc_star(graph: NxMixedGraph, outcomes: Dict[Variable, Intervention], conditions: Dict[Variable, Intervention], *, _number_recursions: int = 0) Expression[source]

Run the IDC* algorithm from [shpitser2012].

Parameters:
  • graph – The causal graph

  • outcomes – The outcome events corresponds to \(\gamma\)

  • conditions – The condition events corresponds to \(\delta\)

  • _number_recursions – The number of times the algorithm has recurred

Returns:

An expression created by the idc_star() algorithm after simplifying the original query

Raises:

ValueError – If ID* returns zero

class Query(outcomes: Variable | set[Variable], treatments: Variable | set[Variable], conditions: None | Variable | set[Variable] = None)[source]

An identification query.

Instantiate an identification.

Parameters:
  • outcomes – The outcomes in the query

  • treatments – The treatments in the query (e.g., counterfactual variables)

  • conditions – The conditions in the query (e.g., coming after the bar)

classmethod from_str(outcomes: str | Iterable[str], treatments: str | Iterable[str], conditions: Iterable[str] | None = None) Query[source]

Construct a query from text variable names.

classmethod from_expression(query: Probability | Distribution) Query[source]

Instantiate an identification.

Parameters:

query – The query probability expression

Returns:

An identification tuple

Raises:

ValueError – If there are ragged counterfactual variables in the query

exchange_observation_with_action(variables: Variable | Iterable[Variable]) Query[source]

Move the condition variable(s) to the treatments.

exchange_action_with_observation(variables: Variable | Iterable[Variable]) Query[source]

Move the treatment variable(s) to the conditions.

with_treatments(extra_treatments: Iterable[Variable]) Query[source]

Create a new identification with additional treatments.

uncondition() Query[source]

Move the conditions to outcomes.

property expression: Expression

Return the query as a Probabilistic expression.

exception Unidentifiable[source]

Raised on failure of the identification algorithm.

class Identification(query: Query, graph: NxMixedGraph, estimand: Expression | None = None)[source]

A package of a query and resulting estimand from identification on a graph.

Instantiate an identification.

Parameters:
  • query – The generalized identification query (outcomes/treatments/conditions)

  • graph – The graph

  • estimand – If none is given, will use the joint distribution over all variables in the graph.

classmethod from_parts(outcomes: set[Variable], treatments: set[Variable], graph: NxMixedGraph, estimand: Expression | None = None, conditions: set[Variable] | None = None) Identification[source]

Instantiate an identification.

Parameters:
  • outcomes – The outcomes in the query

  • treatments – The treatments in the query (e.g., counterfactual variables)

  • conditions – The conditions in the query (e.g., coming after the bar)

  • graph – The graph

  • estimand – If none is given, will use the joint distribution over all variables in the graph.

Returns:

An identification object

classmethod from_expression(*, query: Probability | Distribution, graph: NxMixedGraph, estimand: Expression | None = None) Identification[source]

Instantiate an identification.

Parameters:
  • query – The query probability expression

  • graph – The graph

  • estimand – If none is given, will use the joint distribution over all variables in the graph.

Returns:

An identification object

property outcomes: set[Variable]

Return this identification object’s query’s outcomes.

property treatments: set[Variable]

Return this identification object’s query’s treatments.

property conditions: set[Variable]

Return this identification object’s query’s conditions.

exchange_observation_with_action(variables: Variable | Iterable[Variable]) Identification[source]

Move the condition variable(s) to the treatments.

exchange_action_with_observation(variables: Variable | Iterable[Variable]) Identification[source]

Move the treatment variable(s) to the conditions.

with_treatments(extra_treatments: Iterable[Variable]) Identification[source]

Create a new identification with additional treatments.

uncondition() Identification[source]

Move the conditions to outcomes.