Ewan-Keith / rstansim

R package for running simulation studies with stan
GNU General Public License v3.0
2 stars 1 forks source link

Compatibility with upcoming major update to loo package #2

Open jgabry opened 6 years ago

jgabry commented 6 years ago

Hi @Ewan-Keith, as I mentioned in the email I sent a while back we will be releasing a major update to the loo package (this week I hope) and I wanted to follow up and give you a bit more detail specific to your package. In order to accommodate some new features, the structure of the object returned by loo() is changing slightly. In your case I think you only need to make a few small tweaks to rstansim.

The new loo objects will have a component estimates which is a matrix from which you can pull the required info. For example, if loo_obj is the result from a call to loo then loo_obj$estimates will be a matrix like this:

           Estimate       SE
elpd_loo -83.614057 4.289943
p_loo      3.353629 1.159908
looic    167.228115 8.579885

So in your fit_models-utilities file, you can replace these lines

https://github.com/Ewan-Keith/rstansim/blob/02593d4237b3d37346445b48e91b0df1d8db1947/R/fit_models-utilities.R#L167-L183

with something like this:

    loo_est_matrix <- loo_1$estimates
    loo_output <- data.frame(
      parameter = rep(rownames(loo_est_matrix), 2),
      estimate = rep(c("estimate", "se"), each = 3),
      value = c(loo_est_matrix)
    )

I think that's basically all you need to do, unless there are other files in the package that also compute loo, in which case the same thing applies.

I will send a follow-up email once the loo update is on CRAN but until then you can install it from the master branch at stan-dev/loo if you want to test.

jgabry commented 6 years ago

@Ewan-Keith Just following up to let you know that the loo package update is now on CRAN.