Skip to content

IndexError in GLM using NUTS #2076

@fonnesbeck

Description

@fonnesbeck

Running a GLM that worked in previous versions of PyMC3 now fails when NUTS sampling begins.

with pm.Model() as severity_model:
    
    formula = 'oxygen ~ ' + '+'.join(rsv_vars)
    GLM.from_formula(formula, data=variables, family=families.Binomial())
    severity_trace = pm.sample(2000)

ADVI tuning runs fine, but once sampling begins, an IndexError is raised.

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-63-9a1fc51f9f2d> in <module>()
      6     formula = 'oxygen ~ ' + '+'.join(rsv_vars)
      7     GLM.from_formula(formula, data=variables, family=families.Binomial())
----> 8     severity_trace = pm.sample(2000)

/Users/fonnescj/Repos/pymc3/pymc3/sampling.py in sample(draws, step, init, n_init, start, trace, chain, njobs, tune, nuts_kwargs, step_kwargs, progressbar, model, random_seed, live_plot, **kwargs)
    257         sample_func = _sample
    258 
--> 259     return sample_func(**sample_args)
    260 
    261 

/Users/fonnescj/Repos/pymc3/pymc3/sampling.py in _sample(draws, step, start, trace, chain, tune, progressbar, model, random_seed, live_plot, **kwargs)
    272     try:
    273         strace = None
--> 274         for it, strace in enumerate(sampling):
    275             if live_plot:
    276                 if it >= skip_first:

/Users/fonnescj/anaconda3/envs/dev/lib/python3.6/site-packages/tqdm/_tqdm.py in __iter__(self)
    831 """, fp_write=getattr(self.fp, 'write', sys.stderr.write))
    832 
--> 833             for obj in iterable:
    834                 yield obj
    835                 # Update and print the progressbar.

/Users/fonnescj/Repos/pymc3/pymc3/sampling.py in _iter_sample(draws, step, start, trace, chain, tune, model, random_seed)
    352         _update_start_vals(start, strace.point(-1), model)
    353     else:
--> 354         _update_start_vals(start, model.test_point, model)
    355 
    356     try:

/Users/fonnescj/Repos/pymc3/pymc3/sampling.py in _update_start_vals(a, b, model)
    467         for tname in b:
    468             if tname.startswith(name) and tname!=name:
--> 469                 transform_func = [d.transformation for d in model.deterministics if d.name==name][0]
    470                 b[tname] = transform_func.forward(a[name]).eval()
    471 

IndexError: list index out of range

The model also runs fine with alternative samplers (e.g. Metropolis).

Running current master on macOS and Anaconda Python 3.6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions