Pacific-salmon-assess / MetricsCOSEWIC

R Package for calculating COSEWIC metrics. Initial focus is on Probability of Decline.
GNU General Public License v3.0
0 stars 2 forks source link

Implementation of rstanarm #68

Open carrieholt opened 2 years ago

carrieholt commented 2 years ago

For the implementation of rstanarm in calcPercChangeMCMC(), the code calls stan_lm() with priors=NULL. This means that a flat prior is used, which is strongly recommended against here, https://mc-stan.org/rstanarm/articles/priors.html#how-to-specify-flat-priors-and-why-you-typically-shouldnt (and see the following section on "Specifying flat priors")

https://github.com/SOLV-Code/MetricsCOSEWIC/blob/26d69839e0fbdea63cf7a369575bc8a1ee982d49/R/Module_calcPercChangeMCMC.R#L211-L213

I suggest we switch to the function stan_glm() which includes reasonable default priors for family = "gaussian", and perhaps removing the seed e.g., fit.stan <- stan_glm(Val~Year, family="gaussian", data = stan.in)

This may be moot in the end, as I have coded the model in base stan, but it does help us troubleshoot why the estimates were so different for rstanarm.

SOLV-Code commented 2 years ago

good point!