@@ -85,7 +85,10 @@ def compute_confidence_intervals(self) -> list[float, float]:
85
85
86
86
87
87
class RegressionEstimator (Estimator ):
88
- """ """
88
+ """An abstract class extending the Estimator functionality to add support for formulae, which are used in
89
+ regression based estimators.
90
+
91
+ """
89
92
90
93
def __init__ (
91
94
# pylint: disable=too-many-arguments
@@ -121,7 +124,14 @@ def add_modelling_assumptions(self):
121
124
must hold if the resulting causal inference is to be considered valid.
122
125
"""
123
126
124
- def get_terms_from_formula (self ):
127
+ def get_terms_from_formula (self ) -> tuple (str , str , list [str ]):
128
+ """
129
+ Parse all the terms from a Patsy formula string into outcome, treatment and covariate variables.
130
+
131
+ Formulae are expected to only have a single left hand side term.
132
+
133
+ :return: a truple containing the outcome, treatment and covariate variable names in string format
134
+ """
125
135
desc = ModelDesc .from_formula (self .formula )
126
136
if len (desc .lhs_termlist ) > 1 :
127
137
raise ValueError ("More than 1 left hand side term provided in formula, only single term is accepted" )
@@ -138,6 +148,14 @@ def get_terms_from_formula(self):
138
148
return outcome , self .treatment , covariates
139
149
140
150
def validate_formula (self , causal_dag : CausalDAG ):
151
+ """
152
+ Validate the provided Patsy formula string using the constructive backdoor criterion method found in the
153
+ CausalDAG class
154
+
155
+ :param causal_dag: A CausalDAG object containing for the current test scenario
156
+ :return: True for a formula that does not violate the criteria and False if the formula does violate the
157
+ criteria
158
+ """
141
159
outcome , treatment , covariates = self .get_terms_from_formula ()
142
160
proper_backdoor_graph = causal_dag .get_proper_backdoor_graph (treatments = [treatment ], outcomes = [outcome ])
143
161
return causal_dag .constructive_backdoor_criterion (
0 commit comments