GLEON / LakeMetabolizer

Collection of Lake Metabolism Functions
16 stars 10 forks source link

Bayesian DIC #146

Closed RFlazcano closed 2 years ago

RFlazcano commented 2 years ago

In the bayesian model is there way to extract the DIC for each day and have it be returned in the same way the metabolism estimates or parameters are returned? In model attributes I can see the DIC for each day but just wondering if there's a way to get DIC for each day all at once rather than having to each days attributes to see the DIC.

jzwart commented 2 years ago

Yeah, it's a little convoluted though. If your Bayesian model output is an object called bayes.res, for example, you can see all the model details with

attr(bayes.res, 'model') 

If you just want the DIC values returned for each day, you could run the following:

library(tidyverse)
attr(bayes.res, 'model') %>% purrr::map_df(., ~ tibble(DIC = .x$BUGSoutput$DIC))

output:

# A tibble: 9 x 1
    DIC
  <dbl>
1 -444.
2 -347.
3 -272.
4 -486.
5 -356.
6 -346.
7 -416.
8 -157.
9 -716.
RFlazcano commented 2 years ago

Got it, Thank you!

Would it be acceptable to compare DIC values across days to make a relative assessment on the level of certainty at which the model is predicting the metabolism parameters for that day?

jzwart commented 2 years ago

DIC would be appropriate for comparing different model types to each other that were fit with the same data. But the different days are fit separately so I don't think it'd be appropriate to compare across days. sd of the parameters and metab estiamtes, Rhat values, and R2jags::traceplot() would give you a better idea of how certain the parameters are for given day and across days.