From 1a040c38c01652cfa495c3cff4f75ca1807352a0 Mon Sep 17 00:00:00 2001 From: timjzee Date: Wed, 26 Jun 2024 19:50:46 +0200 Subject: [PATCH] Fix log_lik for multi_normals with >2 variables --- R/ulam_templates.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/ulam_templates.R b/R/ulam_templates.R index f9e8f07..8f00ecf 100644 --- a/R/ulam_templates.R +++ b/R/ulam_templates.R @@ -472,7 +472,9 @@ ulam_dists <- list( out <- concat( out , indent , out_var , " ~ multi_normal( " , MU_var , " , " , SIGMA , " );\n" ) } else { - out <- concat( out , indent , "log_lik = multi_normal_lpdf( " , out_var , " | " , MU_var , " , " , SIGMA , " );\n" ) + out <- concat( out , indent , "for ( j in 1:" , n_cases , " ) {\n" ) + out <- concat( out , indent , indent , "log_lik[j] = multi_normal_lpdf( " , out_var , "[j] | " , MU_var , "[j] , " , SIGMA , " );\n" ) + out <- concat( out , indent , "}\n" ) } # close local environment, if necessary