Skip to content

559: count extension - #593

Open
danielinteractive wants to merge 91 commits into
mainfrom
559-count-extension
Open

danielinteractive wants to merge 91 commits into
mainfrom
559-count-extension

Conversation

@danielinteractive

Copy link
Copy Markdown
Collaborator

continuation of #559

- 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()
…as offset(Length) in the displayed formula.

Fix references too

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Rank-deficient count models, backward-incompatible argument placement, and minimum-R parse failures remain unresolved.

6 open findings
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.

Comment thread R/mcmc_count.R
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) |>
Comment thread R/analyse.R
imputations,
fun = ancova,
delta = NULL,
transform = attr(fun, "transform"),
Comment thread R/draws.R
data_ice = NULL,
vars,
method,
outcome = c("continuous", "count"),
Comment thread R/longData.R
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 thread R/split_time.R
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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants