logProb is -Inf problem

63 views
Skip to first unread message

Bill Chen

unread,
Aug 25, 2023, 8:12:57 AM8/25/23
to nimble...@googlegroups.com
Hello Nimble expert,

I am working on a project where I simulate some dataset to fit different models; however, I got logProb is -Inf problem in even linear model+bym prior. The weird part is some simulated dataset works, but some are not. I think I have messed up something...
Please see the attached files including code and real/simulated dataset. I appreciate any suggestions and insights! 

Best regards,
Bill
Draft_code_nimble.R
County Shapefiles.zip
Y110.RData
mergeus_06072023.RData

Bill Chen

unread,
Aug 25, 2023, 8:20:34 AM8/25/23
to nimble...@googlegroups.com
Also, I forgot to mention that the -inf problem happened after some MCMCsamples did not work out (e.g., NaN in waic, lppd, pwaic values). Thank you so much for your help. 

Bill

Chris Paciorek

unread,
Aug 28, 2023, 9:41:25 PM8/28/23
to Bill Chen, nimble...@googlegroups.com
Hi Bill, I haven't fully worked out what is going on here, but I think it may be that in some chains, one or more values of `mu` in an iteration get so big that they overflow (are set to Infinity) and then the chain goes haywire. It's not hard to get very large values because `mu` is defined as  exp() of the linear predictor, so if in a given iteration that linear predictor gets big enough for even just a single observation, you can get an Inf for a `mu[i]` value. 

One thing that may help is re-scaling all your covariates so that their magnitude is generally not bigger than 1. E.g, you could divide each covariate by the magnitude of the largest covariate value for that covariate (in absolute value). 

To get a better handle on what is happening, try plotting the values of some of the mu[i] over the iterations and see if they end up jumping to very large magnitudes. You could then see how that relates to the values of b1,b2,b3 in particular (and in relation to multiplying those by the covariate values) but also to alpha, u, v. 

Happy to chat further as you dig into this more.

-chris

--
You received this message because you are subscribed to the Google Groups "nimble-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/CAJsVCKR%3DT2eZVzUY%3DwoW1EtgdgezLyFAAo15nPZc5fG-S3n3Jg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages