Repository navigation
559: count extension - #593
Open
danielinteractive wants to merge 91 commits into
Open
danielinteractive wants to merge 91 commits into
danielinteractive wants to merge 91 commits into
Conversation
…k with period instead of visit
- No ICE time is supplied or inferred from duration. - data_ice for count outcomes contains subject ID and strategy only. - A subject’s strategy applies to every missing positive-duration period.
…period is absent from data$periods, listing all unmatched labels.
…med jackknife replicates and the same delta-method logic as pool()
…etails for fixed lambda rate model
…ed before Stan data is constructed.
…as offset(Length) in the displayed formula. Fix references too
There was a problem hiding this comment.
🟡 Changes recommended
Rank-deficient count models, backward-incompatible argument placement, and minimum-R parse failures remain unresolved.
6 open findings
Reject rank-deficient designs before sampling · New Replace native pipe for older R compatibility · New Keep transform after existing arguments · New Append outcome to preserve positional API compatibility · New Preserve documented period level ordering · New Fix malformed Rd backticks in split_time documentation · New
What changed in this PR
Extends rbmi with Bayesian multiple imputation and analysis support for count outcomes.
Changes:
- Adds negative-multinomial modeling, count imputation strategies, simulation, and time splitting.
- Generalizes data validation, pooling, and reporting across endpoint types.
- Adds count-focused tests, vignettes, documentation, and reference data.
| File | Description |
|---|---|
R/analyse.R |
Adds reporting transformations and endpoint-specific analysis classes. |
R/controls.R |
Shares Bayesian control setup across endpoint types. |
R/dataclasses.R |
Adds count posterior sample objects. |
R/draws.R |
Adds count-outcome Bayesian draws. |
R/impute.R |
Generalizes imputation documentation and printing. |
R/impute_count.R |
Implements count strategies and conditional imputation. |
R/longData.R |
Supports ragged period-based data. |
R/mcmc.R |
Dispatches continuous and count Stan models. |
R/mcmc_count.R |
Prepares and extracts count-model Stan data. |
R/methods.R |
Documents count dispersion behavior. |
R/neg_bin_regression.R |
Adds negative-binomial analysis. |
R/pool.R |
Adds endpoint-aware inference and transformations. |
R/scaling.R |
Adds matrix handling and log-link coefficient unscaling. |
R/simulate_count_data.R |
Adds count-data simulation. |
R/split_time.R |
Adds count-period splitting. |
R/utilities.R |
Extends variable and Stan model utilities. |
R/validate_datalong.R |
Validates period and duration data. |
inst/stan/count_model.stan |
Defines the count likelihood. |
inst/extdata/results.csv |
Adds count reference results. |
inst/WORDLIST |
Updates accepted terminology. |
tests/testthat/test-analyse.R |
Tests transformations and endpoint classes. |
tests/testthat/test-controls.R |
Tests shared/count controls. |
tests/testthat/test-counts-fullusage.R |
Exercises the complete count workflow. |
tests/testthat/test-draws-count.R |
Tests count draws and caching. |
tests/testthat/test-draws.R |
Updates subclass expectations. |
tests/testthat/test-impute-count.R |
Tests count imputation behavior. |
tests/testthat/test-mcmc.R |
Tests count Stan preparation and extraction. |
tests/testthat/test-neg-bin-regression.R |
Tests count analysis. |
tests/testthat/test-pool.R |
Tests endpoint inference and transformations. |
tests/testthat/test-scaling.R |
Tests log-link and matrix scaling. |
tests/testthat/test-split-time.R |
Tests time splitting. |
tests/testthat/test-utilities.R |
Tests variable and Stan helpers. |
tests/testthat/test-validate-longdata.R |
Tests period-data validation. |
tests/testthat/helper-misc.R |
Adds an extended-test helper. |
tests/testthat/_snaps/counts-fullusage.md |
Records count workflow snapshots. |
vignettes/count.Rmd |
Documents the count workflow. |
vignettes/count.html |
Provides the rendered count vignette. |
vignettes/count.html.asis |
Registers the count vignette. |
vignettes/stat_specs_counts.Rmd |
Documents count methodology. |
vignettes/stat_specs_counts.html.asis |
Registers count specifications. |
vignettes/stat_specs.Rmd |
Clarifies continuous-only scope. |
vignettes/stat_specs.html |
Updates rendered specifications. |
vignettes/advanced.Rmd |
Documents pooled transformations. |
vignettes/quickstart.Rmd |
Links to count guidance. |
vignettes/quickstart.html |
Updates rendered quickstart. |
vignettes/FAQ.Rmd |
Describes count support. |
vignettes/FAQ.html |
Updates rendered FAQ. |
vignettes/retrieved_dropout.Rmd |
Clarifies continuous scope. |
vignettes/retrieved_dropout.html |
Updates rendered vignette. |
vignettes/CondMean_Inference.Rmd |
Clarifies continuous-only inference. |
vignettes/CondMean_Inference.html |
Updates rendered inference vignette. |
vignettes/references.bib |
Adds endpoint-method references. |
vignettes/build.R |
Builds new count vignettes. |
man/*.Rd |
Documents the expanded public and internal APIs. |
NAMESPACE |
Registers and exports count functionality. |
DESCRIPTION |
Adds dependencies and metadata updates. |
_pkgdown.yml |
Adds count articles to the site. |
NEWS.md |
Announces count support and transformations. |
Files not reviewed (5)
- man/analyse.Rd: Generated file
- man/as_analysis.Rd: Generated file
- man/compile_stan_model.Rd: Generated file
- man/complete_control_bayes_common.Rd: Generated file
- man/complete_control_bayes_count.Rd: Generated file
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| subject_ids <- unique(as.character(subjid)) | ||
| subject_all <- match(as.character(subjid), subject_ids) | ||
|
|
||
| ddat <- as.matrix(ddat[observed, , drop = FALSE]) |
Comment on lines
+38
to
+40
| data |> | ||
| filter(is.na(outcome), duration > 0) |> | ||
| distinct(id) |> |
| imputations, | ||
| fun = ancova, | ||
| delta = NULL, | ||
| transform = attr(fun, "transform"), |
| data_ice = NULL, | ||
| vars, | ||
| method, | ||
| outcome = c("continuous", "count"), |
Comment on lines
581
to
584
| data_nochar <- char2fct( | ||
| data_raw, | ||
| extract_covariates(vars$covariates) | ||
| ) | ||
| # rerun as_dataframe to reset the rownames | ||
| self$data <- as_dataframe(sort_by( | ||
| data_nochar, | ||
| c(vars$subjid, vars$visit) | ||
| )) | ||
| self$vars <- vars | ||
| self$visits <- levels(self$data[[self$vars$visit]]) | ||
| frmvars <- c( | ||
| ife( | ||
| nlevels(self$data[[vars$group]]) >= 2, | ||
| vars$group, | ||
| character() | ||
| ), | ||
| vars$visit, | ||
| vars$covariates | ||
| unique(c(vars$visit, extract_covariates(vars$covariates))) | ||
| ) |
Comment on lines
+22
to
+23
| #' `1970-01-01` for `Date` starts. (Note that `interval = "week"`` with the default | ||
| #' numeric origin 0 / `1970-01-01`` (a Thursday) produces Thursday-based weeks.) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



continuation of #559