Skip to contents

Create the Stan string encompassed by model {}

Usage

make_model_string_model(analysis_obj)

Arguments

analysis_obj

Analysis. Object of class Analysis created by psborrow2:::.analysis_obj().

Value

glue

character containing the Stan code for the data block.

Examples

anls_obj <- psborrow2:::.analysis_obj(
  data_matrix = example_matrix,
  outcome = exp_surv_dist("time", "cnsr"),
  borrowing = borrowing_details(
    "Full borrowing",
    normal_prior(0, 100),
    "ext"
  ),
  treatment = treatment_details("trt", normal_prior(0, 100))
)

psborrow2:::make_model_string_model(anls_obj)
#> model {
#> vector[N] lp;
#> vector[N] elp;
#> beta_trt ~ normal(0, 100); 
#> lp = alpha + trt * beta_trt ;
#> elp = exp(lp);
#> alpha ~ normal(0, 100) ;
#> for (i in 1:N) {
#>    if (cens[i] == 1) {
#>       target += exponential_lccdf(time[i] | elp[i] );
#>    } else {
#>       target += exponential_lpdf(time[i] | elp[i] );
#>    }
#> }
#> }