Skip to content

Commit

Permalink
Merge pull request #1659 from fredcallaway/master
Browse files Browse the repository at this point in the history
allow one-sided patsy formula in linear_component
  • Loading branch information
twiecki committed Jan 10, 2017
2 parents 40ccb10 + 078addd commit 8c87f73
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pymc3/glm/glm.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class linear_component(namedtuple('Estimate', 'y_est,coeffs')):
----------
formula : str
Patsy linear model descriptor.
E.g. 'y ~ a + b' or simply 'a + b'
data : array
Labeled array (e.g. pandas DataFrame, recarray).
priors : dict
Expand Down Expand Up @@ -86,7 +87,10 @@ def __new__(cls, formula, data, priors=None,
priors = defaultdict(None)

# Build patsy design matrix and get regressor names.
_, dmatrix = patsy.dmatrices(formula, data)
try:
_, dmatrix = patsy.dmatrices(formula, data) # 'c ~ a + b'
except patsy.PatsyError:
dmatrix = patsy.dmatrix(formula, data) # 'a + b'
reg_names = dmatrix.design_info.column_names

if init_vals is None:
Expand Down

0 comments on commit 8c87f73

Please sign in to comment.