AndreaNOdell / hake_growth

Spatiotemporal variation in weight-at-age and its impact on fisheries management
2 stars 0 forks source link

Bayesian growth model warnings #4

Closed AndreaNOdell closed 2 years ago

AndreaNOdell commented 2 years ago

Wrote up some code to fit a bayesian growth model using the VB growth model in the 2006 stock assessment which uses a L1 L2 parameterization. I am getting a lot of warnings about divergent transitions, low bulk/tail effective sample sizes, large Rhat, etc. I've only ever fit linear models using stan, so there may actually be an issue with my stan code - could you have a look at it? Warnings suggest increasing the number of iterations and max_treedepth, but wanted to check in with you before I keep running the code (it takes a while). The code can be found in scripts > BayesGrowthModel

kristinmarshall-NOAA commented 2 years ago

Capturing what we already talked about as a general approach to debug (and steps you've already taken I think): 1) Start with a simple non-hierarchical model and build complexity from there once it's running 2) If it's a MCMC sampling issue, can start with tight priors around known values (e.g., a growth model fit outside STAN)

A couple of other things that stuck out to me with the STAN code when I was looking at it just now that may (or may not!) be causing trouble:

https://github.com/AndreaNOdell/hake_growth/blob/604035f0d4c4cff5334e27b4f0905aec0401b2df/scripts/BayesGrowthModel.R#L28

You maybe looked at this already, too, but here is the STAN code for a bayesian VGBF, just to compare syntax, etc. I think this may be the function you fit already.

Just some ideas to try if you're still stuck. Happy to chat tomorrow, too.

AndreaNOdell commented 2 years ago

Gave those a shot (with no success) and spoke with Kiva who suggested using brms, a package that fits bayesian linear and nonlinear multilevel models. Brms worked immediately haha! I also switched the VB parameterization to the one used in the 2006 stock assessment. I first fit a nonlinear fixed effect model to check if it worked, and now currently running the rho random effect model and may check out a K random effect model.

AndreaNOdell commented 2 years ago

Tried brms() and that was an easy solution!