Closed richardmkit closed 1 week ago
I'm not sure what's the issue but I guess you want log_likelihood(..., batch_ndims=0)
. In practice, posterior_samples
are different parameters, so it's more pyroic to use
log_likelihood(handlers.substitute(model, params), {}, Y, batch_ndims=0)
Closed. Please use our forum https://forum.pyro.ai/ for questions.
I write a vector autoregression model like this. I can successfully do the MLE, but after getting the optimal params to compute the log likelihoods for the Hessian matrix, numpyro.infer.log_likelihood doesn't work for this scan-based model. Details below:
The model works, I can successfully back out the parameters (I simulated the data, so the parameters are 100% right), but when I tried to compute log likelihoods, It returned:
Array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], dtype=float32), shaped (2,10000)
All the params are right, Sigma is also positive definite.
Y's shape is (10001,2,1), except the initial point, as long as the internally-bult function log likelihood from NumPyro understands the model, it should at least return a (10000, ) vector instead of (2,10000), because at each time point, Yt's distribution is a 2D MultivariateNormal, given the observed Yt, which should return a scalar. I am not sure whether the combination of scan and log likelihood is allowed and possible?
Wish for your reply and potential solution to just use the built-in log likelihood function.
Best