From 19e6a5e0036b166ddf23220b0b1662a86e72bf1b Mon Sep 17 00:00:00 2001 From: Harrison Date: Fri, 27 Sep 2024 00:41:59 +0100 Subject: [PATCH] Remove for loop around the abs function now the abs function has been vectorised since 2.30 --- src/stan_files/lm.stan | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/stan_files/lm.stan b/src/stan_files/lm.stan index b929c525..dbf46258 100644 --- a/src/stan_files/lm.stan +++ b/src/stan_files/lm.stan @@ -105,11 +105,10 @@ model { if (K > 1) target += beta_lpdf(R2 | half_K, eta); else { - // TODO(Andrew) remove once vectorised abs available in rstan + array[J] real R2_abs; - for (j in 1:J) { - R2_abs[j] = abs(R2[j]); - } + R2_abs = abs(R2); + target += beta_lpdf(square(R2) | half_K, eta) + sum(log(R2_abs)); } }