-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add test with alpha as a RV for negative binomial models. #106
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, for work like this, a report characterizing the data to be fit, the model, and the MCMC results (e.g. posterior trace plots, posterior predictive plots, relevant posterior summary statistics, convergence diagnostics, etc.) needs to be constructed. Without those elements, the only real conclusions that can be drawn are too high-level and/or "syntactic", and there isn't anything that stands out at those levels right now.
In such a report, it would help to confirm that each part is working as expected conditional on the other parts. For instance, does the HSStep
sampler converge as expected when true_alpha
is used in the model? How about the NUTS
estimation of alpha
when beta_true
is used?
Aside from that, perhaps alpha
around 100 results in a large-ish overdispersion—under NegativeBinomial
's parameterization—relative to a mean like exp(X.dot(beta))
for the given X
and beta_true
. If the "true" model generates mean values around 500 on average, then the negative-binomial variance is six times the corresponding Poisson model variance, I believe. This isn't necessarily bad, but it could be adding some understandable signal-to-noise trouble that prevents a quick recovery of the "true" parameters.
Here is a notebook report on the findings. After I reduce the alpha parameter to smaller value. I think the |
This is very helpful! It's missing a plot of the simulated data, though, which would help illustrate some of the challenges in this simulation. For instance, I'm pretty sure that the variance is very large.
I think the results you're seeing are likely a result of a relatively small number of observations, a large variance, a small MCMC sample size, and/or the choice of It's difficult to see where the true values lie relative to the posterior distributions (see my comment), but none of them look too far off from the true values—at least not in a way that clearly implies systematic bias or the like. Aside from that, all of your Contrary to what you wrote in that notebook, it looks like the last model (i.e. with Also, care needs to be taken when choosing priors for constrained parameters. In this case, To help move past some of the ambiguities in the current simulation, try
You can also try decreasing the magnitude of the true |
Updated notebook 1 Increased number of obs to 500 I think the prior did quite affect the ability of convergence quite a bit. Base on the toy setup it usually results in about 10% off from the true alpha. |
Do you think one of these would work as a test? |
438712d
to
f9a9afd
Compare
This PR added test for NB with an
alpha
as RV. However, it seems like that the samples in the toy model set up could not converge close enough to the realalpha
Where
assert np.abs(trace.posterior.alpha.values[0].mean(0) - true_alpha)/true_alpha < 0.1
would not be able to pass even with very large number of samples.