Skip to content

LKJ prior doesn't seem to work in PyMC v4, raises TypeError #5361

Closed
@martiningram

Description

@martiningram

Hi all,

Description of your problem

I'm trying to fit a model with an LKJ prior on the covariance matrix using PyMC v4. I'm running the example notebook, available in the repository here; the only change I've made is to switch from

import pymc3 as pm

to

import pymc as pm

All runs fine, until we get to this line:

with pm.Model() as m:
    packed_L = pm.LKJCholeskyCov("packed_L", n=2, eta=2.0, sd_dist=pm.Exponential.dist(1.0))

This gives the following error:

TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_55195/2070945655.py in <module>
      1 with pm.Model() as m:
----> 2     packed_L = pm.LKJCholeskyCov("packed_L", n=2, eta=2.0, sd_dist=pm.Exponential.dist(1.0))

~/projects/pymc3_vs_stan/pymc/pymc/distributions/multivariate.py in LKJCholeskyCov(name, eta, n, sd_dist, compute_corr, store_in_trace, *args, **kwargs)
   1390     """
   1391     # compute Cholesky decomposition
-> 1392     packed_chol = _LKJCholeskyCov(name, eta=eta, n=n, sd_dist=sd_dist)
   1393     if not compute_corr:
   1394         return packed_chol

~/projects/pymc3_vs_stan/pymc/pymc/distributions/distribution.py in __new__(cls, name, rng, dims, initval, observed, total_size, transform, *args, **kwargs)
    253         # Create the RV and process dims and observed to determine
    254         # a shape by which the created RV may need to be resized.
--> 255         rv_out, dims, observed, resize_shape = _make_rv_and_resize_shape(
    256             cls=cls, dims=dims, model=model, observed=observed, args=args, rng=rng, **kwargs
    257         )

~/projects/pymc3_vs_stan/pymc/pymc/distributions/distribution.py in _make_rv_and_resize_shape(cls, dims, model, observed, args, **kwargs)
    152     # Create the RV without dims information, because that's not something tracked at the Aesara level.
    153     # If necessary we'll later replicate to a different size implied by already known dims.
--> 154     rv_out = cls.dist(*args, **kwargs)
    155     ndim_actual = rv_out.ndim
    156     resize_shape = None

TypeError: dist() missing 1 required positional argument: 'dist_params'

Versions and main components

  • PyMC/PyMC3 Version: v4.0.0b2
  • Aesara/Theano Version: 2.3.2
  • Python Version: 3.8.12
  • Operating system: Ubuntu
  • How did you install PyMC/PyMC3: (conda/pip) pip install -e . from the repo

Let me know if you have any questions. Thanks for your help!

Best wishes,
Martin

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