Why can't I replicate the lognormal model in sdmTMB with other methods? #132
-
Question that @kellijohnson-NOAA and I were asked this week: I'd like to use sdmTMB for non-spatial index standardization. I was comparing it to fitting a model with Stan (and combining the results myself). The estimates of year effects are off in sdmTMB -- why? This example with the positive model is using the positive density:
And when I fit a model using
Note: fitting the model in
The sdmTMB estimates are perfectly correlated with the Bayesian ones, but off by a scale. So it doesn't affect the trend of the index -- but it does impact the absolute biomass estimates. Why is sdmTMB different? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The issue is that sdmTMB implements the widely used bias correction factor for the lognormal distribution, -sigma^ 2 / 2.0. This is in the code here: Line 749 in be1ec3a The above approaches -- which either log-transform then fit a model with a Gaussian response, or use a lognormal family with an identity link, don't include the bias correction term. You could fit the same model yourself, with the following Stan code
And when we compare the estimates with the custom Stan code, they perfectly match the sdmTMB estimates: <style> </style>
For very small values of sigma, these results will be more similar -- but for many cases, it's a good idea to include the bias correction term, as is in sdmTMB |
Beta Was this translation helpful? Give feedback.
The issue is that sdmTMB implements the widely used bias correction factor for the lognormal distribution, -sigma^ 2 / 2.0. This is in the code here:
sdmTMB/src/sdmTMB.cpp
Line 749 in be1ec3a
The above approaches -- which either log-transform then fit a model with a Gaussian response, or use a lognormal family with an identity link, don't include the bias correction term.
You could fit the same model yourself, with the following Stan code