Skip to content
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

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

Closed
martiningram opened this issue Jan 16, 2022 · 2 comments
Closed

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

martiningram opened this issue Jan 16, 2022 · 2 comments

Comments

@martiningram
Copy link
Contributor

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

@twiecki
Copy link
Member

twiecki commented Jan 16, 2022

Unfortunately LKJ is still missing, there's an unfinished PR that we need someone to push over the finish line: #4784

@twiecki twiecki closed this as completed Jan 16, 2022
@martiningram
Copy link
Contributor Author

I see, thanks Thomas! I'll wait for that PR then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants