Skip to content

Error When Evaluating Log Likelihood for MvGaussianRandomWalk #2858

Closed
@a3huang

Description

@a3huang

When I initialize a MvGaussianRandomWalk distribution using the cov keyword and try to evaluate the log likelihood as follows:

pm.MvGaussianRandomWalk.dist(mu=tt.constant([1,1]), cov=tt.constant(np.eye(2))).logp(tt.constant([[1,2]])).eval()

I get the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-308-59dbcd30652a> in <module>()
----> 1 pm.MvGaussianRandomWalk.dist(mu=tt.constant([1,1]), cov=tt.constant(np.eye(2))).logp(tt.constant([[1,2]])).eval()

/Users/alexhuang/Library/Python/2.7/lib/python/site-packages/pymc3/distributions/timeseries.pyc in logp(self, x)
    357 
    358         innov_like = multivariate.MvNormal.dist(mu=x_im1 + self.mu, cov=self.cov,
--> 359                                                 tau=self.tau, chol=self.chol_cov).logp(x_i)
    360         return self.init.logp(x[0]) + tt.sum(innov_like)
    361 

/Users/alexhuang/Library/Python/2.7/lib/python/site-packages/pymc3/distributions/distribution.pyc in dist(cls, *args, **kwargs)
     45     def dist(cls, *args, **kwargs):
     46         dist = object.__new__(cls)
---> 47         dist.__init__(*args, **kwargs)
     48         return dist
     49 

/Users/alexhuang/Library/Python/2.7/lib/python/site-packages/pymc3/distributions/multivariate.pyc in __init__(self, mu, cov, tau, chol, lower, *args, **kwargs)
    220                  *args, **kwargs):
    221         super(MvNormal, self).__init__(mu=mu, cov=cov, tau=tau, chol=chol,
--> 222                                        lower=lower, *args, **kwargs)
    223         self.mean = self.median = self.mode = self.mu = self.mu
    224 

/Users/alexhuang/Library/Python/2.7/lib/python/site-packages/pymc3/distributions/multivariate.pyc in __init__(self, mu, cov, chol, tau, lower, *args, **kwargs)
     39             chol = chol.T
     40         if len([i for i in [tau, cov, chol] if i is not None]) != 1:
---> 41             raise ValueError('Incompatible parameterization. '
     42                              'Specify exactly one of tau, cov, '
     43                              'or chol.')

ValueError: Incompatible parameterization. Specify exactly one of tau, cov, or chol.

However, if I instead use the tau or chol keywords, it runs fine.

Digging into it, it looks like the __initCov__ function of _CovSet sets values for variables self.cov and self.chol_cov when we provide a covariance matrix via cov. However, this causes an error when we initialize the MvNormal in the logp function of MvGaussianRandomWalk because both cov and chol end up being passed into the initializer for MvNormal and then to _QuadFormBase which expects that only one of cov, tau, or chol is provided.

Is this the expected behavior?

  • PyMC3 Version: 3.3
  • Theano Version: 1.0.1
  • Python Version: 2.7.12
  • Operating system: MacOS 10.13.3
  • How did you install PyMC3: pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions