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 13, 2024
1 parent 839266c commit 6e4c0e1
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(

Check warning on line 52 in inst/cohort-scratch.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=inst/cohort-scratch.R,line=52,col=1,[object_length_linter] Variable and function names should not be longer than 30 characters.
"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 6e4c0e1

Please sign in to comment.