From 33b97f9c3000d64a7443d5b20e8c28f5d4d344e0 Mon Sep 17 00:00:00 2001 From: Sam Abbott Date: Thu, 12 Sep 2024 14:52:00 +0100 Subject: [PATCH 1/2] simplify epred --- R/latent_gamma.R | 3 +-- R/latent_lognormal.R | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/R/latent_gamma.R b/R/latent_gamma.R index fc9ca4859..95ddced02 100644 --- a/R/latent_gamma.R +++ b/R/latent_gamma.R @@ -43,8 +43,7 @@ posterior_predict_latent_gamma <- function(i, prep, ...) { # nolint: object_leng #' @autoglobal #' @keywords internal posterior_epred_latent_gamma <- function(prep) { # nolint: object_length_linter - mu <- brms::get_dpar(prep, "mu") - mu + brms::get_dpar(prep, "mu") } #' Calculate the pointwise log likelihood of the `latent_gamma` family diff --git a/R/latent_lognormal.R b/R/latent_lognormal.R index a8c14a409..7020eda7a 100644 --- a/R/latent_lognormal.R +++ b/R/latent_lognormal.R @@ -44,9 +44,7 @@ posterior_predict_latent_lognormal <- function(i, prep, ...) { # nolint: object_ #' @autoglobal #' @keywords internal posterior_epred_latent_lognormal <- function(prep) { # nolint: object_length_linter - mu <- brms::get_dpar(prep, "mu") - sigma <- brms::get_dpar(prep, "sigma") - exp(mu + sigma^2 / 2) + with(prep$dpars, exp(mu + sigma^2 / 2)) } #' Calculate the pointwise log likelihood of the `latent_gamma` family From d787344102334c513bff2ef9592eb561c8cb8f17 Mon Sep 17 00:00:00 2001 From: athowes Date: Thu, 12 Sep 2024 17:08:52 +0100 Subject: [PATCH 2/2] Revert latent_lognormal epred --- R/latent_lognormal.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/latent_lognormal.R b/R/latent_lognormal.R index 7020eda7a..a8c14a409 100644 --- a/R/latent_lognormal.R +++ b/R/latent_lognormal.R @@ -44,7 +44,9 @@ posterior_predict_latent_lognormal <- function(i, prep, ...) { # nolint: object_ #' @autoglobal #' @keywords internal posterior_epred_latent_lognormal <- function(prep) { # nolint: object_length_linter - with(prep$dpars, exp(mu + sigma^2 / 2)) + mu <- brms::get_dpar(prep, "mu") + sigma <- brms::get_dpar(prep, "sigma") + exp(mu + sigma^2 / 2) } #' Calculate the pointwise log likelihood of the `latent_gamma` family