Skip to content

Commit 12b1ddb

Browse files
committed
fix: add missing L parameter to primarycensored_lpmf Stan call
primarycensored >= 1.4.0 added a left truncation parameter (L) to all Stan function signatures. The marginal model Stan template was missing this parameter, causing Stan compilation failures for all users. Also adds primarycensored >= 1.4.0 version bound to DESCRIPTION and extends check-cmdstan CI to cover marginal model syntax. Closes #583
1 parent 13d05ae commit 12b1ddb

3 files changed

Lines changed: 30 additions & 4 deletions

File tree

.github/workflows/check-cmdstan.yaml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
cmdstan-version: 'latest'
5353
num-cores: 2
5454

55-
- name: Compile model and check syntax
55+
- name: Check latent model syntax
5656
run: |
5757
dummy_obs <- dplyr::tibble(
5858
pdate_lwr = as.Date("2020-01-01"),
@@ -77,3 +77,29 @@ jobs:
7777
all(message == "Stan program is syntactically correct")
7878
)
7979
shell: Rscript {0}
80+
81+
- name: Check marginal model syntax
82+
run: |
83+
dummy_obs <- dplyr::tibble(
84+
pdate_lwr = as.Date("2020-01-01"),
85+
sdate_lwr = as.Date("2020-02-01")
86+
)
87+
dummy_obs <- epidist::as_epidist_linelist_data(dummy_obs)
88+
dummy_obs <- suppressMessages(
89+
epidist::as_epidist_marginal_model(dummy_obs)
90+
)
91+
stancode <- epidist::epidist(
92+
data = dummy_obs, fn = brms::make_stancode
93+
)
94+
mod <- cmdstanr::cmdstan_model(
95+
stan_file = cmdstanr::write_stan_file(stancode), compile = FALSE
96+
)
97+
message <- capture.output(
98+
mod$check_syntax(pedantic = FALSE),
99+
type = "message"
100+
)
101+
stopifnot(
102+
length(message) != 0 &&
103+
all(message == "Stan program is syntactically correct")
104+
)
105+
shell: Rscript {0}

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Imports:
4141
cli,
4242
dplyr,
4343
lubridate,
44-
primarycensored,
44+
primarycensored (>= 1.4.0),
4545
purrr,
4646
rstan (>= 2.26.0),
4747
stats,

inst/stan/marginal_model/functions.stan

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
data real y_upper, array[] real primary_params) {
2424

2525
return primarycensored_lpmf(
26-
y | dist_id, {dpars_B}, pwindow_width, y_upper, relative_obs_t,
27-
primary_id, primary_params
26+
y | dist_id, {dpars_B}, pwindow_width, y_upper,
27+
0, relative_obs_t, primary_id, primary_params
2828
);
2929
}

0 commit comments

Comments
 (0)