No default priors - #284
Conversation
Codecov Report❌ Patch coverage is
|
Merge commit '3b4716133fef058c422a27876729a296fdf1a4d6' #Conflicts: # DESCRIPTION # NEWS.md
|
@claude, review |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@claude, review |
|
Claude finished review — View run Review: #284 — "No default priors"This is a follow-up review. Since the prior review (commit Previously-flagged issues: status#1 — #2 —
fitted_stratified <- run_serodynamics(
data = stratified_data,
file_mod = serodynamics_example("model.jags"),
nchain = 2,
nadapt = 100,
nburn = 100,
nmc = 10,
niter = 20,
strat = "pathogen" # Specify stratification variable
)No prior arguments are supplied and there is no #3 — Fixture/data-raw regeneration scripts — Fixed. #4 — No test coverage for mandatory-argument behavior — Fixed. Two new tests added in #5 — Stale roxygen #6 — NEWS.md entry undersells breaking change — Partially fixed. The entry was moved from
Not flagged (checked, no issue)
VerdictNeeds more work — finding #2 (the Reviewed commit: 4908763 |
… in getting started
…rrect prior param
There was a problem hiding this comment.
Pull request overview
This PR removes default prior values from the modeling workflow and updates package docs/examples/tests so users must explicitly provide priors when running run_serodynamics() (and prep_priors() now defaults prior inputs to NULL).
Changes:
- Removed default prior arguments from
prep_priors()and updated tests/fixtures to supply explicit priors. - Updated user-facing examples (vignette +
inst/examples) and Rd docs to reflect the new “no default priors” behavior. - Added/updated NEWS + bumped package version.
Reviewed changes
Copilot reviewed 15 out of 18 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| vignettes/articles/getting-started.qmd | Updates getting-started examples to pass priors explicitly. |
| tests/testthat/test-runjags.R | Updates test to call prep_priors() with explicit prior vectors. |
| tests/testthat/test-run_serodynamics.R | Updates integration-style tests to pass priors explicitly into run_serodynamics(). |
| tests/testthat/test-prep_priors.R | Removes snapshot of default priors; adds tests for erroring when priors omitted and for exponential priors. |
| tests/testthat/fixtures/make-example-runjags-inputs.R | Updates fixture generator to supply explicit priors. |
| tests/testthat/fixtures/make_example_runjags_output.R | Updates fixture generator to supply explicit priors. |
| tests/testthat/_snaps/prep_priors.md | Updates snapshots to reflect changed prep_priors() behavior. |
| R/run_serodynamics.R | Updates roxygen text to state priors must be specified. |
| R/prep_priors.R | Removes default priors (defaults now NULL), adds decay_type arg, and updates validation/docs. |
| NEWS.md | Documents the breaking change (no default priors). |
| man/run_serodynamics.Rd | Regenerated docs/examples to include explicit prior arguments. |
| man/prep_priors.Rd | Regenerated docs to reflect new prep_priors() signature and guidance. |
| man/postprocess_jags_output.Rd | Regenerated docs/examples to include explicit priors. |
| inst/examples/run_serodynamics-examples.R | Updates examples to pass priors explicitly. |
| inst/examples/postprocess_jags_output-examples.R | Updates examples to pass priors explicitly. |
| inst/examples/examples-prep_priors.R | Removes example that relied on default priors. |
| DESCRIPTION | Bumps development version. |
| data-raw/nepal_sees_jags_output.R | Updates data-raw script to pass priors explicitly. |
Files not reviewed (3)
- man/postprocess_jags_output.Rd: Generated file
- man/prep_priors.Rd: Generated file
- man/run_serodynamics.Rd: Generated file
Suppressed comments (2)
R/prep_priors.R:29
- The
omega_paramdocumentation currently says both that exponential uses 4 values and that the vector must be 5 values long, and it also has a)..typo. The length requirements should be stated consistently (5 for power, 4 for exponential).
#' @param omega_param A [numeric] [vector] of 5 values corresponding to the
#' diagonal entries representing the Wishart hyperprior
#' distributions of `prec_hyp_param`, describing how much we expect parameters
#' to vary between individuals (4 values
#' when `decay_type == "exponential"`)..
#' Must be 5 values long corresponding to the 5 estimated parameters.
tests/testthat/test-prep_priors.R:37
- Similar to the test above:
expect_error()without checking the message can mask regressions (e.g., failing earlier for the wrong reason). Consider asserting the specific exponential-length error (4 priors formu_hyp_param).
test_that("Expect error for mu.hyp.param under exponential", {
prep_priors(max_antigens = 2,
mu_hyp_param = c(1.0),
prec_hyp_param = c(0.01),
omega_param = c(1.0),
wishdf_param = 15,
prec_logy_hyp_param = c(4.0, 1.0),
decay_type = "exponential") |>
expect_error()
})
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@claude, please review and recommend changes regarding the failing R-CMD-check from windows. |
imelainew
left a comment
There was a problem hiding this comment.
Looks good! Ready for Ezra from my side.
|
Hi @d-morrison, this PR is ready for your review. It is not passing the windows R-CMD check, but it looks like it is a rjags installation issue that may require workflow changes, which I am hesitant to jump into myself. Thank you for taking a look. |
| n_params <- 5 # Assuming 5 model parameters [ y0, y1, t1, alpha, shape] | ||
| n_params <- if (decay_type == "power") 5L else 4L |
There was a problem hiding this comment.
I have a question about order right: y0, y1, t1, alpha, shape, and it matches model.jags where position 4 is alpha and position 5 is log(shape minus 1). But the roxygen for mu_hyp_param above lists it as y0, y1, t1, r, alpha, which swaps the last two, and then the sentence below that says exponential uses y0, y1, t1, alpha, contradicting its own list. That ordering was already wrong on main, but it matters more now that exponential requires exactly 4 values: someone following the roxygen list will pass the shape prior as their fourth value and it will be used as the prior on log alpha with no error. Worth fixing the roxygen to match this line while you're in here.
Two smaller things in the same block: the exponential sentence says 5 parameters where it should say 4, and the returns section still describes n_params as 5 and the array dimensions as max_antigens by 5.
Taking away default priors and forcing users to input their priors manually. Changing documentation accordingly including examples. Priors are now listed as NULL in the input for prep_priors().
Prep_priors was also changed to correspond with the input decay type -- 5 for power and 4 for exponential for mu_hyp, prec_hyp, and omega.