Skip to content

Commit

Permalink
array to vector
Browse files Browse the repository at this point in the history
to test again!
  • Loading branch information
n8thangreen committed Aug 28, 2024
1 parent 7d5c712 commit f105bd3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions inst/stan/include/distributions.stan
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,19 @@ real surv_weibull_lpdf (real t, real d, real shape, real scale) {
return log_lik;
}

// take additional arguments for integration
real weibull_survival_1d(real t, real xc, array[] real theta, array[] real x_r, array[] int x_i) {
// Define the function to be integrated
real weibull_survival_1d(real t, real xc, vector theta, data vector x_r, data int x_i) {
real shape = theta[1];
real scale = theta[2];
return exp(-pow(t / scale, shape));
}

// restricted mean survival time
// Restricted mean survival time
real rmst_weibull(real shape, real scale, real tmax) {
real rmst;
array[2] real theta = {shape, scale};
array[0] real x_r;
array[0] int x_i;
vector[2] theta = [shape, scale];
vector[0] x_r; // zero-sized vector
int[0] x_i; // zero-sized int array

// integrate survival function from 0 to tmax
rmst = integrate_1d(weibull_survival_1d, 0, tmax, theta, x_r, x_i, 1e-8);
Expand Down

0 comments on commit f105bd3

Please sign in to comment.