:py:mod:`causal_testing.estimation.linear_regression_estimator` =============================================================== .. py:module:: causal_testing.estimation.linear_regression_estimator .. autoapi-nested-parse:: This module contains the LinearRegressionEstimator for estimating continuous outcomes. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: causal_testing.estimation.linear_regression_estimator.LinearRegressionEstimator Attributes ~~~~~~~~~~ .. autoapisummary:: causal_testing.estimation.linear_regression_estimator.logger .. py:data:: logger .. py:class:: LinearRegressionEstimator(base_test_case: causal_testing.testing.base_test_case.BaseTestCase, treatment_value: float, control_value: float, adjustment_set: set, df: pandas.DataFrame = None, effect_modifiers: dict[causal_testing.specification.variable.Variable, Any] = None, formula: str = None, alpha: float = 0.05, query: str = '') Bases: :py:obj:`causal_testing.estimation.abstract_regression_estimator.RegressionEstimator` A Linear Regression Estimator is a parametric estimator which restricts the variables in the data to a linear combination of parameters and functions of the variables (note these functions need not be linear). .. py:attribute:: regressor .. py:method:: gp_formula(ngen: int = 100, pop_size: int = 20, num_offspring: int = 10, max_order: int = 0, extra_operators: list = None, sympy_conversions: dict = None, seeds: list = None, seed: int = 0) Use Genetic Programming (GP) to infer the regression equation from the data. :param ngen: The maximum number of GP generations to run for. :param pop_size: The GP population size. :param num_offspring: The number of offspring per generation. :param max_order: The maximum polynomial order to use, e.g. ``max_order=2`` will give polynomials of the form ``ax^2 + bx + c``. :param extra_operators: Additional operators for the GP (defaults are +, \*, log(x), and 1/x). Operations should be of the form (fun, numArgs), e.g. (add, 2). :param sympy_conversions: Dictionary of conversions of extra_operators for sympy, e.g. ``"mul": lambda \*args_: "Mul({},{})".format(\*args_)``. :param seeds: Seed individuals for the population (e.g. if you think that the relationship between X and Y is probably logarithmic, you can put that in). :param seed: Random seed for the GP. .. py:method:: estimate_coefficient() -> causal_testing.estimation.effect_estimate.EffectEstimate Estimate the unit average treatment effect of the treatment on the outcome. That is, the change in outcome caused by a unit change in treatment. :return: The unit average treatment effect and the 95% Wald confidence intervals. .. py:method:: estimate_ate() -> causal_testing.estimation.effect_estimate.EffectEstimate Estimate the average treatment effect of the treatment on the outcome. That is, the change in outcome caused by changing the treatment variable from the control value to the treatment value. :return: The average treatment effect and the 95% Wald confidence intervals. .. py:method:: estimate_risk_ratio(adjustment_config: dict = None) -> causal_testing.estimation.effect_estimate.EffectEstimate Estimate the risk_ratio effect of the treatment on the outcome. That is, the change in outcome caused by changing the treatment variable from the control value to the treatment value. :return: The average treatment effect and the 95% Wald confidence intervals. .. py:method:: estimate_ate_calculated(adjustment_config: dict = None) -> causal_testing.estimation.effect_estimate.EffectEstimate Estimate the ATE of the treatment on the outcome. That is, the change in outcome caused by changing the treatment variable from the control value to the treatment value. Here, we actually calculate the expected outcomes under control and treatment and divide one by the other. This allows for custom terms to be put in such as squares, inverses, products, etc. :param: adjustment_config: The configuration of the adjustment set as a dict mapping variable names to their values. N.B. Every variable in the adjustment set MUST have a value in order to estimate the outcome under control and treatment. :return: The average treatment effect and the 95% Wald confidence intervals. .. py:method:: _get_confidence_intervals(model, treatment)