![]() |
aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
|
Builds a CausalFormula for a query (d-sep -> backdoor -> frontdoor -> (optional) do-calculus). More...
#include <causalImpact.h>
Public Member Functions | |
| Tensor< GUM_SCALAR > | eval () const |
| Evaluates the formula's AST to compute the resulting probability distribution. | |
| std::string | toString () const |
| Generates a string representation of the formula's AST. | |
| std::string | toLatex (std::string_view doOperatorPrefix="do(", std::string_view doOperatorSuffix=")") const |
| Generates a full LaTeX equation: Query = Formula. | |
| std::string | latexQuery (std::string_view doOperatorPrefix="do(", std::string_view doOperatorSuffix=")") const |
| Generates a LaTeX representation of the original query, e.g., P(Y | do(X), Z). | |
| bool | isIdentified () const noexcept |
| Whether the causal effect has been identified. | |
| const ASTtree< GUM_SCALAR > & | root () const |
| Access the root AST node of the identified formula. | |
| const CausalFormula< GUM_SCALAR > & | getResult () const |
| Access the underlying CausalFormula result. | |
| const CausalModel< GUM_SCALAR > & | cm () const |
| const NodeSet & | on () const |
| const NodeSet & | doing () const |
| const NodeSet & | knowing () const |
| const std::string & | explanation () const |
| std::vector< std::string > | onNames () const |
| Convenience: return names corresponding to stored node ids (sorted). | |
| std::vector< std::string > | doingNames () const |
| std::vector< std::string > | knowingNames () const |
| CausalImpact (const CausalModel< GUM_SCALAR > &cm, const Set< std::string > &on, const Set< std::string > &doing, const Set< std::string > &knowing=Set< std::string >(), bool directDoCalculus=false) | |
| Constructs a CausalImpact object using variable names. | |
| CausalImpact (const CausalModel< GUM_SCALAR > &cm, const NodeSet &on, const NodeSet &doing, const NodeSet &knowing=NodeSet(), bool directDoCalculus=false) | |
| Constructs a CausalImpact object using node IDs. | |
| CausalImpact (const CausalImpact &)=default | |
| Copy/move constructors — defaulted; require CausalFormula to be copy/move-constructible. | |
| CausalImpact (CausalImpact &&)=default | |
Static Private Member Functions | |
| static Set< std::string > | _idsToNames_ (const CausalModel< GUM_SCALAR > &cm, const NodeSet &ids) |
| static NodeSet | _namesToIds_ (const CausalModel< GUM_SCALAR > &cm, const Set< std::string > &names) |
| static bool | _disjoint_ (const Set< std::string > &a, const Set< std::string > &b, const Set< std::string > &c) |
| static CausalFormula< GUM_SCALAR > | _buildFromNames_ (const CausalModel< GUM_SCALAR > &cm, const Set< std::string > &on, const Set< std::string > &doing, const Set< std::string > &knowing, bool directDoCalculus) |
| static CausalFormula< GUM_SCALAR > | _buildFromIds_ (const CausalModel< GUM_SCALAR > &cm, const NodeSet &on, const NodeSet &doing, const NodeSet &knowing, bool directDoCalculus) |
Private Attributes | |
| bool | _directDoCalculus_ = false |
| If true, skip backdoor/frontdoor and use do-calculus directly. | |
| CausalFormula< GUM_SCALAR > | _resultFormula_ |
| Identified symbolic formula. If not identifiable, its AST may be nullptr and its explanation string (6th ctor arg) will say so. | |
Builds a CausalFormula for a query (d-sep -> backdoor -> frontdoor -> (optional) do-calculus).
With your CausalFormula’s API (no default ctor, non-assignable), we compute the AST first and initialize result in the initializer list (single shot).
Definition at line 82 of file causalImpact.h.
| gum::CausalImpact< GUM_SCALAR >::CausalImpact | ( | const CausalModel< GUM_SCALAR > & | cm, |
| const Set< std::string > & | on, | ||
| const Set< std::string > & | doing, | ||
| const Set< std::string > & | knowing = Set< std::string >(), | ||
| bool | directDoCalculus = false ) |
Constructs a CausalImpact object using variable names.
| cm | The causal model to use for identification. |
| on | The set of variable names representing the outcome(s) of interest. |
| doing | The set of variable names representing the intervention(s) (do-variables). |
| knowing | The set of variable names representing observed covariates (optional). |
| directDoCalculus | If true, bypasses Backdoor and Frontdoor and directly uses the ID algorithm for identification. |
Definition at line 151 of file causalImpact_tpl.h.
References _buildFromNames_(), _directDoCalculus_, _resultFormula_, cm(), doing(), knowing(), and on().
Referenced by CausalImpact(), and CausalImpact().
| gum::CausalImpact< GUM_SCALAR >::CausalImpact | ( | const CausalModel< GUM_SCALAR > & | cm, |
| const NodeSet & | on, | ||
| const NodeSet & | doing, | ||
| const NodeSet & | knowing = NodeSet(), | ||
| bool | directDoCalculus = false ) |
Constructs a CausalImpact object using node IDs.
| cm | The causal model to use for identification. |
| on | The set of node IDs representing the outcome(s) of interest. |
| doing | The set of node IDs representing the intervention(s) (do-variables). |
| knowing | The set of node IDs representing observed covariates (optional). |
| directDoCalculus | If true, bypasses Backdoor and Frontdoor and directly uses the ID algorithm for identification. |
Definition at line 160 of file causalImpact_tpl.h.
References cm().
|
default |
Copy/move constructors — defaulted; require CausalFormula to be copy/move-constructible.
References CausalImpact().
|
default |
|
staticprivate |
Definition at line 286 of file causalImpact_tpl.h.
References _buildFromNames_(), _idsToNames_(), cm(), doing(), knowing(), and on().
|
staticprivate |
Definition at line 172 of file causalImpact_tpl.h.
References _disjoint_(), _namesToIds_(), cm(), doing(), GUM_ERROR, knowing(), and on().
Referenced by CausalImpact(), and _buildFromIds_().
|
staticprivate |
Definition at line 132 of file causalImpact_tpl.h.
Referenced by _buildFromNames_().
|
staticprivate |
Definition at line 113 of file causalImpact_tpl.h.
References cm(), and gum::Set< Key >::insert().
Referenced by _buildFromIds_().
|
staticprivate |
Definition at line 123 of file causalImpact_tpl.h.
References cm(), and gum::Set< Key >::insert().
Referenced by _buildFromNames_().
| const CausalModel< GUM_SCALAR > & gum::CausalImpact< GUM_SCALAR >::cm | ( | ) | const |
Definition at line 385 of file causalImpact_tpl.h.
References _resultFormula_.
Referenced by CausalImpact(), CausalImpact(), _buildFromIds_(), _buildFromNames_(), _idsToNames_(), and _namesToIds_().
| const NodeSet & gum::CausalImpact< GUM_SCALAR >::doing | ( | ) | const |
Definition at line 395 of file causalImpact_tpl.h.
References _resultFormula_.
Referenced by CausalImpact(), _buildFromIds_(), and _buildFromNames_().
| std::vector< std::string > gum::CausalImpact< GUM_SCALAR >::doingNames | ( | ) | const |
Definition at line 415 of file causalImpact_tpl.h.
References _resultFormula_.
| Tensor< GUM_SCALAR > gum::CausalImpact< GUM_SCALAR >::eval | ( | ) | const |
Evaluates the formula's AST to compute the resulting probability distribution.
Definition at line 348 of file causalImpact_tpl.h.
References _resultFormula_.
Referenced by gum::causalImpact().
| const std::string & gum::CausalImpact< GUM_SCALAR >::explanation | ( | ) | const |
Definition at line 405 of file causalImpact_tpl.h.
References _resultFormula_.
Referenced by gum::causalImpact().
| const CausalFormula< GUM_SCALAR > & gum::CausalImpact< GUM_SCALAR >::getResult | ( | ) | const |
Access the underlying CausalFormula result.
Definition at line 380 of file causalImpact_tpl.h.
References _resultFormula_.
|
nodiscardnoexcept |
Whether the causal effect has been identified.
Returns true iff this formula has a valid AST (i.e., identification succeeded and evaluation is possible). When this returns false, calling root() or eval() will throw.
Definition at line 370 of file causalImpact_tpl.h.
References _resultFormula_.
Referenced by gum::causalImpact().
| const NodeSet & gum::CausalImpact< GUM_SCALAR >::knowing | ( | ) | const |
Definition at line 400 of file causalImpact_tpl.h.
References _resultFormula_.
Referenced by CausalImpact(), _buildFromIds_(), and _buildFromNames_().
| std::vector< std::string > gum::CausalImpact< GUM_SCALAR >::knowingNames | ( | ) | const |
Definition at line 420 of file causalImpact_tpl.h.
References _resultFormula_.
| std::string gum::CausalImpact< GUM_SCALAR >::latexQuery | ( | std::string_view | doOperatorPrefix = "do(", |
| std::string_view | doOperatorSuffix = ")" ) const |
Generates a LaTeX representation of the original query, e.g., P(Y | do(X), Z).
Definition at line 364 of file causalImpact_tpl.h.
References _resultFormula_.
| const NodeSet & gum::CausalImpact< GUM_SCALAR >::on | ( | ) | const |
Definition at line 390 of file causalImpact_tpl.h.
References _resultFormula_.
Referenced by CausalImpact(), _buildFromIds_(), and _buildFromNames_().
| std::vector< std::string > gum::CausalImpact< GUM_SCALAR >::onNames | ( | ) | const |
Convenience: return names corresponding to stored node ids (sorted).
Definition at line 410 of file causalImpact_tpl.h.
References _resultFormula_.
| const ASTtree< GUM_SCALAR > & gum::CausalImpact< GUM_SCALAR >::root | ( | ) | const |
Access the root AST node of the identified formula.
Use this to inspect the symbolic structure of the identified effect.
| gum::OperationNotAllowed | if no AST is available (i.e., the effect is not identifiable with the current methods). |
Definition at line 375 of file causalImpact_tpl.h.
References _resultFormula_.
| std::string gum::CausalImpact< GUM_SCALAR >::toLatex | ( | std::string_view | doOperatorPrefix = "do(", |
| std::string_view | doOperatorSuffix = ")" ) const |
Generates a full LaTeX equation: Query = Formula.
Definition at line 358 of file causalImpact_tpl.h.
References _resultFormula_.
| std::string gum::CausalImpact< GUM_SCALAR >::toString | ( | ) | const |
Generates a string representation of the formula's AST.
Definition at line 353 of file causalImpact_tpl.h.
References _resultFormula_.
|
private |
If true, skip backdoor/frontdoor and use do-calculus directly.
Definition at line 191 of file causalImpact.h.
Referenced by CausalImpact().
|
private |
Identified symbolic formula. If not identifiable, its AST may be nullptr and its explanation string (6th ctor arg) will say so.
Definition at line 195 of file causalImpact.h.
Referenced by CausalImpact(), cm(), doing(), doingNames(), eval(), explanation(), getResult(), isIdentified(), knowing(), knowingNames(), latexQuery(), on(), onNames(), root(), toLatex(), and toString().