Skip to content

Commit

Permalink
Wrap up on attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
athowes committed Nov 15, 2024
1 parent 473ddc1 commit c226df9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions inst/cohort-scratch.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ summary(fit_direct_weighted)

lognormal <- brms::lognormal()

primarycensored_lognormal_uniform_lpmf <- brms::custom_family(
primarycensored_lognormal_uniform <- brms::custom_family(
"primarycensored_lognormal_uniform",
dpars = lognormal$dpar,
links = c(lognormal$link, lognormal$link_sigma),
Expand Down Expand Up @@ -92,7 +92,7 @@ stanvars_all <- stanvars_functions + stanvars_data

stancode <- brms::make_stancode(
formula = d | weights(n) + vreal(q) ~ 1,
family = primarycensored_lognormal_uniform_lpmf,
family = primarycensored_lognormal_uniform,
data = data,
stanvars = stanvars_all,
)
Expand All @@ -101,7 +101,7 @@ model <- rstan::stan_model(model_code = stancode)

fit_pcd <- brms::brm(
formula = d | weights(n) + vreal(q) ~ 1,
family = primarycensored_lognormal_uniform_lpmf,
family = primarycensored_lognormal_uniform,
data = data,
stanvars = stanvars_all,
backend = "cmdstanr"
Expand Down
6 changes: 4 additions & 2 deletions inst/stan/cohort_model/primarycensored-edit.stan
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// Edited to work with temporary brms function

real primarycensored_lognormal_uniform_lpmf(data int d, real mu, real sigma, real q, data real pwindow) {
int dist_id = 1; // lognormal
array[2] real params = {mu, sigma};
array[0] real primary_params;
int d_upper = d + 1;
return primarycensored_lpmf(d | 1, params, pwindow, d_upper, positive_infinity(), 1, primary_params);
int primary_id = 1; // Uniform
array[0] real primary_params;
return primarycensored_lpmf(d | dist_id, params, pwindow, d_upper, positive_infinity(), primary_id, primary_params);
}

/**
Expand Down

0 comments on commit c226df9

Please sign in to comment.