From 7d5c712d297df8f179a0fcbe2b6df0641c2170da Mon Sep 17 00:00:00 2001 From: Dr Nathan Green Date: Wed, 28 Aug 2024 19:19:38 +0100 Subject: [PATCH] try array[] --- inst/stan/include/distributions.stan | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/inst/stan/include/distributions.stan b/inst/stan/include/distributions.stan index af7cd99..4368274 100644 --- a/inst/stan/include/distributions.stan +++ b/inst/stan/include/distributions.stan @@ -131,25 +131,18 @@ real surv_weibull_lpdf (real t, real d, real shape, real scale) { } // take additional arguments for integration -real weibull_survival_1d(real t, real xc, real[] theta, real[] x_r, int[] x_i) { +real weibull_survival_1d(real t, real xc, array[] real theta, array[] real x_r, array[] int x_i) { real shape = theta[1]; real scale = theta[2]; return exp(-pow(t / scale, shape)); } // restricted mean survival time -//// this may be wrong accoring to chat-gpt -// real rmst_weibull (real shape, real scale, real tmax) { -// real rmst; -// rmst = scale^(-1/shape) * gamma_q(scale*tmax^shape, 1/shape + 1) + tmax*exp(-scale*tmax^shape); -// return rmst; -// } -//TODO: test new formulation real rmst_weibull(real shape, real scale, real tmax) { real rmst; - real[] theta = {shape, scale}; - real[] x_r = {}; - int[] x_i = {}; + array[2] real theta = {shape, scale}; + array[0] real x_r; + array[0] int x_i; // integrate survival function from 0 to tmax rmst = integrate_1d(weibull_survival_1d, 0, tmax, theta, x_r, x_i, 1e-8);