|
| 1 | +import warnings |
1 | 2 | from typing import Union
|
2 | 3 |
|
3 | 4 | import arviz as az
|
@@ -864,22 +865,28 @@ class InstrumentalVariable(ExperimentalDesign):
|
864 | 865 | A class to analyse instrumental variable style experiments.
|
865 | 866 |
|
866 | 867 | :param instruments_data: A pandas dataframe of instruments
|
867 |
| - for our treatment variable |
| 868 | + for our treatment variable. Should contain |
| 869 | + instruments Z, and treatment t |
868 | 870 | :param data: A pandas dataframe of covariates for fitting
|
869 |
| - the focal regression of interest |
| 871 | + the focal regression of interest. Should contain covariates X |
| 872 | + including treatment t and outcome y |
870 | 873 | :param instruments_formula: A statistical model formula for
|
871 | 874 | the instrumental stage regression
|
872 |
| - :param formula: A statistical model formula for the focal regression |
| 875 | + e.g. t ~ 1 + z1 + z2 + z3 |
| 876 | + :param formula: A statistical model formula for the \n |
| 877 | + focal regression e.g. y ~ 1 + t + x1 + x2 + x3 |
873 | 878 | :param model: A PyMC model
|
874 | 879 | :param priors: An optional dictionary of priors for the
|
875 | 880 | mus and sigmas of both regressions. If priors are not
|
876 | 881 | specified we will substitue MLE estimates for the beta
|
877 |
| - coefficients |
| 882 | + coefficients. Greater control can be achieved |
| 883 | + by specifying the priors directly e.g. priors = { |
| 884 | + "mus": [0, 0], |
| 885 | + "sigmas": [1, 1], |
| 886 | + "eta": 2, |
| 887 | + "lkj_sd": 2, |
| 888 | + } |
878 | 889 |
|
879 |
| - .. note:: |
880 |
| -
|
881 |
| - There is no pre/post intervention data distinction for the instrumental variable |
882 |
| - design, we fit all the data available. |
883 | 890 | """
|
884 | 891 |
|
885 | 892 | def __init__(
|
@@ -969,3 +976,10 @@ def _input_validation(self):
|
969 | 976 | as an outcome variable and in the data object to be used as a covariate.
|
970 | 977 | """
|
971 | 978 | )
|
| 979 | + check_binary = len(self.data[treatment.strip()].unique()) > 2 |
| 980 | + if check_binary: |
| 981 | + warnings.warn( |
| 982 | + """Warning. The treatment variable is not Binary. \n |
| 983 | + This is not necessarily a problem but it complicates \n |
| 984 | + the interpretation of the model coefficients.""" |
| 985 | + ) |
0 commit comments