-
Notifications
You must be signed in to change notification settings - Fork 89
Add variable selection priors #568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
1f4f695
2a01933
db1e81d
db0522e
1670af4
83061e4
05dc20d
73e6a8d
8d6251f
4577106
fd1bfb7
7375aa5
896ee57
1bb79d3
068c922
13b320e
6210116
bf5b404
b16ef30
b88271e
c452650
a5dd60f
2578cce
a7c1090
78ed0ce
9e6ede0
dbc8614
12936a4
97090b8
6e7accf
4b315fd
ca37024
18da6c4
a466161
8020248
452a63c
f377505
2576b66
4dae630
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,4 +41,5 @@ | |
| "RegressionKink", | ||
| "skl_models", | ||
| "SyntheticControl", | ||
| "variable_selection_priors", | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,12 @@ class InstrumentalVariable(BaseExperiment): | |
| If priors are not specified we will substitute MLE estimates for | ||
| the beta coefficients. Example: ``priors = {"mus": [0, 0], | ||
| "sigmas": [1, 1], "eta": 2, "lkj_sd": 2}``. | ||
| :param vs_prior_type : str or None, default=None | ||
| Type of variable selection prior: 'spike_and_slab', 'horseshoe', or None. | ||
| If None, uses standard normal priors. | ||
| :param vs_hyperparams : dict, optional | ||
|
||
| Hyperparameters for variable selection priors. Only used if vs_prior_type | ||
| is not None. | ||
|
|
||
| Example | ||
| -------- | ||
|
|
@@ -98,6 +104,8 @@ def __init__( | |
| formula: str, | ||
| model: BaseExperiment | None = None, | ||
| priors: dict | None = None, | ||
| vs_prior_type=None, | ||
| vs_hyperparams=None, | ||
| **kwargs: dict, | ||
| ) -> None: | ||
| super().__init__(model=model) | ||
|
|
@@ -107,6 +115,8 @@ def __init__( | |
| self.formula = formula | ||
| self.instruments_formula = instruments_formula | ||
| self.model = model | ||
| self.vs_prior_type = (vs_prior_type,) | ||
| self.vs_hyperparams = vs_hyperparams or {} | ||
| self.input_validation() | ||
|
|
||
| y, X = dmatrices(formula, self.data) | ||
|
|
@@ -138,7 +148,14 @@ def __init__( | |
| } | ||
| self.priors = priors | ||
| self.model.fit( # type: ignore[call-arg,union-attr] | ||
| X=self.X, Z=self.Z, y=self.y, t=self.t, coords=COORDS, priors=self.priors | ||
| X=self.X, | ||
| Z=self.Z, | ||
| y=self.y, | ||
| t=self.t, | ||
| coords=COORDS, | ||
| priors=self.priors, | ||
| vs_prior_type=vs_prior_type, | ||
| vs_hyperparams=vs_hyperparams, | ||
NathanielF marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
NathanielF marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| def input_validation(self) -> None: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing import for variable_selection_priors module export
The
variable_selection_priorsmodule is added to__all__but there's no corresponding import statement in the file. Other modules likepymc_modelsandskl_modelshave explicit imports (e.g.,import causalpy.pymc_models as pymc_models), but this pattern is missing forvariable_selection_priors. This causesfrom causalpy import variable_selection_priorsandfrom causalpy import *to fail with an import error.