Open seananderson opened 11 months ago
I believe this needs the variance from the smoothers included. We'd need to multiply the basis functions by their corresponding penalized coefficients + add on any linear component. Alternatively, as an easy hack, we could predict without standard errors and without any random effects and call all that the 'fixed effect' component if there are smoothers.
I have done a bunch of work on this in this file: https://github.com/pbs-assess/sdmTMB/blob/main/scratch/r2-glmm.qmd including adding smoothers, changing how the distribution variance is calculated, and checking against the performance package/glmmTMB.
I've taken a first stab at bringing the r2.sdmTMB()
function into the package. See progress here: https://github.com/pbs-assess/sdmTMB/compare/r2?expand=1 which compares the 'r2' branch with 'main'.
Still to do:
Integrate work @maxlindmark and @federico-maioli sent me (thanks!), which includes R2 for other families: https://gist.github.com/seananderson/96c36fae8d23879e388aa7ab9a601f60
Edit: don't use the above, use the newer: https://github.com/pbs-assess/sdmTMB/blob/main/scratch/r2-glmm.qmd