xfim / ggmcmc

Graphical tools for analyzing Markov Chain Monte Carlo simulations from Bayesian inference
111 stars 31 forks source link

Fix: Error in ggs_geweke from 0-var check in sde0f function #63

Closed brianstock closed 5 years ago

brianstock commented 6 years ago

Hello,

I wrote and maintain a package that depends on ggmcmc (MixSIAR). In one of my updates, I encountered an error stemming from ggs_geweke, which I traced to sde0f.

The error was surprising, because it occurred for a JAGS model with an informative prior, but NOT for the same model with the same data using an uninformative prior. My guess is the issue occurs for a parameter with nearly 0 variance. Your check for 0 variance in sde0f was length(unique(x)) > 0, but an alternative solution from Stack Overflow seems more robust in my case:

0 != var(if (is.factor(x)) as.integer(x) else x)

When I make this change to sde0f I get no errors with ggs_geweke for either model.

aijawhite commented 6 years ago

Thank you! This fix worked for the error code in my case too.

xfim commented 5 years ago

Thank you.