From e6fd6ff432b690e0f68225fe8b3179bef9384364 Mon Sep 17 00:00:00 2001 From: Craig Gower-Page Date: Wed, 19 Jun 2024 17:18:33 +0100 Subject: [PATCH] Improve Stan Function Name(#363) --- inst/stan/base/functions.stan | 8 ++++---- inst/stan/lm-gsf/functions.stan | 2 +- inst/stan/lm-gsf/link_dsld.stan | 2 +- inst/stan/lm-stein-fojo/functions.stan | 2 +- inst/stan/lm-stein-fojo/link_dsld.stan | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/inst/stan/base/functions.stan b/inst/stan/base/functions.stan index 2e2c1979a..387792699 100644 --- a/inst/stan/base/functions.stan +++ b/inst/stan/base/functions.stan @@ -84,19 +84,19 @@ functions { // Replaces the values of `y` with `replacement` if the corresponding value // of `x` is less than 0. - matrix if_lt0_else(matrix x, matrix y, real replacement) { + matrix if_gte0_else(matrix x, matrix y, real replacement) { matrix[rows(x), cols(x)] result; for (i in 1:rows(x)) { for (j in 1:cols(x)) { - result[i, j] = x[i, j] < 0 ? replacement : y[i, j]; + result[i, j] = x[i, j] >= 0 ? y[i, j] : replacement; } } return result; } - vector if_lt0_else(vector x, vector y, real replacement) { + vector if_gte0_else(vector x, vector y, real replacement) { vector[rows(x)] result; for (i in 1:rows(x)) { - result[i] = x[i] < 0 ? replacement : y[i]; + result[i] = x[i] >= 0 ? y[i] : replacement; } return result; } diff --git a/inst/stan/lm-gsf/functions.stan b/inst/stan/lm-gsf/functions.stan index 140a9a076..0b71cbec4 100644 --- a/inst/stan/lm-gsf/functions.stan +++ b/inst/stan/lm-gsf/functions.stan @@ -12,7 +12,7 @@ functions { vector psi_phi ) { int nrow = rows(time); - vector[nrow] psi_phi_mod = if_lt0_else(time, psi_phi, 0); + vector[nrow] psi_phi_mod = if_gte0_else(time, psi_phi, 0); vector[nrow] result = fmin( 8000.0, diff --git a/inst/stan/lm-gsf/link_dsld.stan b/inst/stan/lm-gsf/link_dsld.stan index 69c88b548..febb677d1 100644 --- a/inst/stan/lm-gsf/link_dsld.stan +++ b/inst/stan/lm-gsf/link_dsld.stan @@ -22,7 +22,7 @@ functions { matrix[nrows, ncols] psi_kg_matrix = rep_matrix(psi_kg, ncols); matrix[nrows, ncols] psi_phi_matrix = rep_matrix(psi_phi, ncols); - psi_phi_matrix = if_lt0_else(time, psi_phi_matrix, 0); + psi_phi_matrix = if_gte0_else(time, psi_phi_matrix, 0); matrix[nrows, ncols] result = fmin( 8000.0, diff --git a/inst/stan/lm-stein-fojo/functions.stan b/inst/stan/lm-stein-fojo/functions.stan index 0f603560a..1c69244e1 100644 --- a/inst/stan/lm-stein-fojo/functions.stan +++ b/inst/stan/lm-stein-fojo/functions.stan @@ -11,7 +11,7 @@ functions { vector psi_kg ) { int n = rows(time); - vector[n] psi_ks_mod = if_lt0_else(time, psi_ks, 0); + vector[n] psi_ks_mod = if_gte0_else(time, psi_ks, 0); vector[n] result = fmin( 8000.0, psi_bsld .* ( diff --git a/inst/stan/lm-stein-fojo/link_dsld.stan b/inst/stan/lm-stein-fojo/link_dsld.stan index 5dd260dbd..120b422d8 100644 --- a/inst/stan/lm-stein-fojo/link_dsld.stan +++ b/inst/stan/lm-stein-fojo/link_dsld.stan @@ -20,7 +20,7 @@ functions { matrix[nrows, ncols] psi_ks_matrix = rep_matrix(psi_ks, ncols); matrix[nrows, ncols] psi_kg_matrix = rep_matrix(psi_kg, ncols); - matrix[nrows, ncols] psi_ks_matrix_mod = if_lt0_else(time, psi_ks_matrix, 0); + matrix[nrows, ncols] psi_ks_matrix_mod = if_gte0_else(time, psi_ks_matrix, 0); matrix[nrows, ncols] result = fmin( 8000.0,