From b87a6cb1e6d96b1576f4ea7f358abe7cc7809144 Mon Sep 17 00:00:00 2001 From: Emma Date: Sun, 5 Mar 2023 15:10:31 -0500 Subject: [PATCH 1/5] Added reward values to bart_ewmv --- commons/stan_files/bart_ewmv.stan | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/commons/stan_files/bart_ewmv.stan b/commons/stan_files/bart_ewmv.stan index 4d521150..e8c1afb8 100644 --- a/commons/stan_files/bart_ewmv.stan +++ b/commons/stan_files/bart_ewmv.stan @@ -71,7 +71,9 @@ model { real p_burst = phi[j]; for (k in 1:Tsubj[j]) { - real u_gain = 1; + // real u_gain = 1; + // Reward values based on pump number + row_vector[11] u_gain_array = [0.05, 0.15, 0.25, 0.55, 0.95, 1.45, 2.05, 2.75, 3.45, 4.25, 5.15]; real u_loss; real u_pump; real u_stop = 0; @@ -80,8 +82,7 @@ model { for (l in 1:(pumps[j, k] + 1 - explosion[j, k])) { u_loss = (l - 1); - u_pump = (1 - p_burst) * u_gain - lambda[j] * p_burst * u_loss + - rho[j] * p_burst * (1 - p_burst) * (u_gain + lambda[j] * u_loss)^2; + u_pump = (1 - p_burst) * u_gain_array[l] - lambda[j] * p_burst * u_loss + rho[j] * p_burst * (1 - p_burst) * (u_gain_array[l] + lambda[j] * u_loss)^2; // u_stop always equals 0. delta_u = u_pump - u_stop; @@ -131,7 +132,9 @@ generated quantities { log_lik[j] = 0; for (k in 1:Tsubj[j]) { - real u_gain = 1; + // real u_gain = 1; + // Reward values based on pump number + row_vector[11] u_gain_array = [0.05, 0.15, 0.25, 0.55, 0.95, 1.45, 2.05, 2.75, 3.45, 4.25, 5.15]; real u_loss; real u_pump; real u_stop = 0; @@ -141,8 +144,8 @@ generated quantities { // u_gain always equals r ^ rho. u_loss = (l - 1); - u_pump = (1 - p_burst) * u_gain - lambda[j] * p_burst * u_loss + - rho[j] * p_burst * (1 - p_burst) * (u_gain + lambda[j] * u_loss)^2; + // Updated to use u_gain_array values + u_pump = (1 - p_burst) * u_gain_array[l] - lambda[j] * p_burst * u_loss + rho[j] * p_burst * (1 - p_burst) * (u_gain_array[l] + lambda[j] * u_loss)^2; // u_stop always equals 0. delta_u = u_pump - u_stop; From 17308ae7fc61feaf8c913c48e61511078007da5a Mon Sep 17 00:00:00 2001 From: Emma Date: Fri, 17 Mar 2023 20:22:49 -0400 Subject: [PATCH 2/5] changing value of balloon to reward --- commons/stan_files/bart_ewmv.stan | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commons/stan_files/bart_ewmv.stan b/commons/stan_files/bart_ewmv.stan index e8c1afb8..234d02b6 100644 --- a/commons/stan_files/bart_ewmv.stan +++ b/commons/stan_files/bart_ewmv.stan @@ -73,7 +73,7 @@ model { for (k in 1:Tsubj[j]) { // real u_gain = 1; // Reward values based on pump number - row_vector[11] u_gain_array = [0.05, 0.15, 0.25, 0.55, 0.95, 1.45, 2.05, 2.75, 3.45, 4.25, 5.15]; + row_vector[11] u_gain_array = [0.05, 0.10, 0.10, 0.30, 0.40, .50, .60, .70, .70, .80, .90]; real u_loss; real u_pump; real u_stop = 0; @@ -134,7 +134,7 @@ generated quantities { for (k in 1:Tsubj[j]) { // real u_gain = 1; // Reward values based on pump number - row_vector[11] u_gain_array = [0.05, 0.15, 0.25, 0.55, 0.95, 1.45, 2.05, 2.75, 3.45, 4.25, 5.15]; + row_vector[11] u_gain_array = [0.05, 0.10, 0.10, 0.30, 0.40, .50, .60, .70, .70, .80, .90]; real u_loss; real u_pump; real u_stop = 0; From 2f531d2950840ee96403757152766baca51c7317 Mon Sep 17 00:00:00 2001 From: Emma Date: Fri, 26 Jan 2024 19:49:48 -0500 Subject: [PATCH 3/5] Fix bart_ewmv formula to properly include reward --- commons/stan_files/bart_ewmv.stan | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commons/stan_files/bart_ewmv.stan b/commons/stan_files/bart_ewmv.stan index 234d02b6..64d5d0e0 100644 --- a/commons/stan_files/bart_ewmv.stan +++ b/commons/stan_files/bart_ewmv.stan @@ -145,7 +145,7 @@ generated quantities { u_loss = (l - 1); // Updated to use u_gain_array values - u_pump = (1 - p_burst) * u_gain_array[l] - lambda[j] * p_burst * u_loss + rho[j] * p_burst * (1 - p_burst) * (u_gain_array[l] + lambda[j] * u_loss)^2; + u_pump = (1 - p_burst) * u_gain_array[l] - lambda[j] * p_burst * u_loss * u_gain_array[l] + rho[j] * p_burst * (1 - p_burst) * (u_gain_array[l] + lambda[j] * u_loss * u_gain_array[l])^2; // u_stop always equals 0. delta_u = u_pump - u_stop; From 31b5194bb08a80acf6a7a7225e50bf7e320c431d Mon Sep 17 00:00:00 2001 From: Emma Date: Mon, 29 Jan 2024 15:46:29 -0500 Subject: [PATCH 4/5] Add in u_lose_array to bart_ewmv --- commons/stan_files/bart_ewmv.stan | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/commons/stan_files/bart_ewmv.stan b/commons/stan_files/bart_ewmv.stan index 64d5d0e0..5f4b70d4 100644 --- a/commons/stan_files/bart_ewmv.stan +++ b/commons/stan_files/bart_ewmv.stan @@ -135,6 +135,7 @@ generated quantities { // real u_gain = 1; // Reward values based on pump number row_vector[11] u_gain_array = [0.05, 0.10, 0.10, 0.30, 0.40, .50, .60, .70, .70, .80, .90]; + row_vector[11] u_lose_array = [0, 0.05, 0.15, 0.25, 0.55, 0.95, 1.45, 2.05, 2.75, 3.45, 4.25, 5.15]; real u_loss; real u_pump; real u_stop = 0; @@ -142,10 +143,13 @@ generated quantities { for (l in 1:(pumps[j, k] + 1 - explosion[j, k])) { // u_gain always equals r ^ rho. - u_loss = (l - 1); + + // Because our reward gain is not constant across the trail, we need to use the summation of the previous rewards. + // This is pre-populated in the u_lose_array + // u_loss = (l - 1); // Updated to use u_gain_array values - u_pump = (1 - p_burst) * u_gain_array[l] - lambda[j] * p_burst * u_loss * u_gain_array[l] + rho[j] * p_burst * (1 - p_burst) * (u_gain_array[l] + lambda[j] * u_loss * u_gain_array[l])^2; + u_pump = (1 - p_burst) * u_gain_array[l] - lambda[j] * p_burst * u_lose_array[l] + rho[j] * p_burst * (1 - p_burst) * (u_gain_array[l] + lambda[j] * u_lose_array[l])^2; // u_stop always equals 0. delta_u = u_pump - u_stop; From d379248e191a4a4e7fc773a409ef303646925482 Mon Sep 17 00:00:00 2001 From: Emma Date: Mon, 29 Jan 2024 16:03:43 -0500 Subject: [PATCH 5/5] Update missed function --- commons/stan_files/bart_ewmv.stan | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/commons/stan_files/bart_ewmv.stan b/commons/stan_files/bart_ewmv.stan index 5f4b70d4..577fd85f 100644 --- a/commons/stan_files/bart_ewmv.stan +++ b/commons/stan_files/bart_ewmv.stan @@ -74,15 +74,18 @@ model { // real u_gain = 1; // Reward values based on pump number row_vector[11] u_gain_array = [0.05, 0.10, 0.10, 0.30, 0.40, .50, .60, .70, .70, .80, .90]; + row_vector[11] u_lose_array = [0, 0.05, 0.15, 0.25, 0.55, 0.95, 1.45, 2.05, 2.75, 3.45, 4.25, 5.15]; real u_loss; real u_pump; real u_stop = 0; real delta_u; for (l in 1:(pumps[j, k] + 1 - explosion[j, k])) { - u_loss = (l - 1); - - u_pump = (1 - p_burst) * u_gain_array[l] - lambda[j] * p_burst * u_loss + rho[j] * p_burst * (1 - p_burst) * (u_gain_array[l] + lambda[j] * u_loss)^2; + // Because our reward gain is not constant across the trail, we need to use the summation of the previous rewards. + // This is pre-populated in the u_lose_array + // u_loss = (l - 1); + + u_pump = (1 - p_burst) * u_gain_array[l] - lambda[j] * p_burst * u_lose_array[l] + rho[j] * p_burst * (1 - p_burst) * (u_gain_array[l] + lambda[j] * u_lose_array[l])^2; // u_stop always equals 0. delta_u = u_pump - u_stop;