pbs-assess / sdmTMB

:earth_americas: An R package for spatial and spatiotemporal GLMMs with TMB
https://pbs-assess.github.io/sdmTMB/
183 stars 26 forks source link

Add R2 function #256

Open seananderson opened 11 months ago

seananderson commented 11 months ago

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

seananderson commented 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.

seananderson commented 11 months ago

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.

seananderson commented 10 months ago

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: