InstrumentalVariable#

class causalpy.pymc_experiments.InstrumentalVariable[source]#

A class to analyse instrumental variable style experiments.

Parameters:
  • instruments_data (DataFrame) – A pandas dataframe of instruments for our treatment variable. Should contain instruments Z, and treatment t

  • data (DataFrame) – A pandas dataframe of covariates for fitting the focal regression of interest. Should contain covariates X including treatment t and outcome y

  • instruments_formula (str) – A statistical model formula for the instrumental stage regression e.g. t ~ 1 + z1 + z2 + z3

  • formula (str) –

    A statistical model formula for the

    focal regression e.g. y ~ 1 + t + x1 + x2 + x3

  • model – A PyMC model

  • priors

    An optional dictionary of priors for the mus and sigmas of both regressions. If priors are not specified we will substitue MLE estimates for the beta coefficients. Greater control can be achieved by specifying the priors directly e.g. priors = {

    ”mus”: [0, 0], “sigmas”: [1, 1], “eta”: 2, “lkj_sd”: 2, }

Methods

InstrumentalVariable.__init__(...[, model, ...])

InstrumentalVariable.get_2SLS_fit()

Two Stage Least Squares Fit

InstrumentalVariable.get_naive_OLS_fit()

Naive Ordinary Least Squares

InstrumentalVariable.print_coefficients([...])

Prints the model coefficients

Attributes

expt_type

idata

Access to the models InferenceData object

model

__init__(instruments_data, data, instruments_formula, formula, model=None, priors=None, **kwargs)[source]#
Parameters:
__new__(*args, **kwargs)#