From dbab7da68e6aa3861982a51e892dde60d7ec0b1b Mon Sep 17 00:00:00 2001 From: Niels Dunnewind Date: Fri, 18 Oct 2024 22:25:10 +0200 Subject: [PATCH] Implement baseline risk meta-regression for other models --- inst/stan/binomial_1par.stan | 1 + inst/stan/binomial_2par.stan | 5 +++++ inst/stan/normal.stan | 5 +++++ inst/stan/ordered_multinomial.stan | 5 +++++ inst/stan/poisson.stan | 5 +++++ 5 files changed, 21 insertions(+) diff --git a/inst/stan/binomial_1par.stan b/inst/stan/binomial_1par.stan index a0ec7dbe..79e8ed20 100644 --- a/inst/stan/binomial_1par.stan +++ b/inst/stan/binomial_1par.stan @@ -34,6 +34,7 @@ transformed parameters { X_agd_arm * beta_tilde + offset_agd_arm : X_agd_arm * beta_tilde; + // Baseline risk meta-regression if (brmr_n_col > 0) { eta_agd_arm_noRE += (X_agd_arm[,1:totns] * mu - xbar_mu - 1) .* (X_agd_arm[,brmr_col] * beta_tilde[brmr_col]); } diff --git a/inst/stan/binomial_2par.stan b/inst/stan/binomial_2par.stan index 76cdb550..e541406c 100644 --- a/inst/stan/binomial_2par.stan +++ b/inst/stan/binomial_2par.stan @@ -37,6 +37,11 @@ transformed parameters { X_agd_arm * beta_tilde + offset_agd_arm : X_agd_arm * beta_tilde; + // Baseline risk meta-regression + if (brmr_n_col > 0) { + eta_agd_arm_noRE += (X_agd_arm[,1:totns] * mu - xbar_mu - 1) .* (X_agd_arm[,brmr_col] * beta_tilde[brmr_col]); + } + if (nint_max > 1) { // -- If integration points are used -- if (RE) { diff --git a/inst/stan/normal.stan b/inst/stan/normal.stan index 2b9bcd94..187dc3d8 100644 --- a/inst/stan/normal.stan +++ b/inst/stan/normal.stan @@ -39,6 +39,11 @@ transformed parameters { X_agd_arm * beta_tilde + offset_agd_arm : X_agd_arm * beta_tilde; + // Baseline risk meta-regression + if (brmr_n_col > 0) { + eta_agd_arm_noRE += (X_agd_arm[,1:totns] * mu - xbar_mu - 1) .* (X_agd_arm[,brmr_col] * beta_tilde[brmr_col]); + } + if (nint_max > 1) { // -- If integration points are used -- if (RE) { diff --git a/inst/stan/ordered_multinomial.stan b/inst/stan/ordered_multinomial.stan index 7bf77d2b..13e30793 100644 --- a/inst/stan/ordered_multinomial.stan +++ b/inst/stan/ordered_multinomial.stan @@ -87,6 +87,11 @@ transformed parameters { X_agd_arm * beta_tilde + offset_agd_arm : X_agd_arm * beta_tilde; + // Baseline risk meta-regression + if (brmr_n_col > 0) { + eta_agd_arm_noRE += (X_agd_arm[,1:totns] * mu - xbar_mu - 1) .* (X_agd_arm[,brmr_col] * beta_tilde[brmr_col]); + } + if (nint_max > 1) { // -- If integration points are used -- if (RE) { diff --git a/inst/stan/poisson.stan b/inst/stan/poisson.stan index 05dda8f9..02b39c7c 100644 --- a/inst/stan/poisson.stan +++ b/inst/stan/poisson.stan @@ -34,6 +34,11 @@ transformed parameters { X_agd_arm * beta_tilde + offset_agd_arm : X_agd_arm * beta_tilde; + // Baseline risk meta-regression + if (brmr_n_col > 0) { + eta_agd_arm_noRE += (X_agd_arm[,1:totns] * mu - xbar_mu - 1) .* (X_agd_arm[,brmr_col] * beta_tilde[brmr_col]); + } + if (nint_max > 1) { // -- If integration points are used -- if (RE) {