Conversation
…n validation - Added support for variability formulas in the simulate_data function, allowing users to specify a formula for variability alongside the main formula. - Implemented dimension validation to ensure that simulated data does not exceed the dimensions of the original model, preventing potential errors during simulation. - Introduced a new utility function to normalize sum-to-zero vector parameters in posterior draws, addressing floating-point precision issues. - Updated Stan model to accommodate new design matrices for random effects and variability, ensuring compatibility with existing functionality. - Added comprehensive unit tests to validate the new features and ensure robustness against various model configurations.
- Introduced `sccomp_simulate` function for simulating data from fitted models, enhancing usability and flexibility. - Deprecated the `simulate_data` function, providing a warning to users to transition to `sccomp_simulate`. - Updated documentation to reflect changes and provide clear guidance on the new function's usage. - Enhanced unit tests to validate the new simulation functionality and ensure compatibility with existing workflows. - Adjusted Stan model to accommodate new parameters for user-provided coefficients, improving simulation accuracy and performance.
- Added validation to ensure user-provided coefficients sum to zero within a specified tolerance, crucial for compositional models. - Implemented checks using tidyverse to identify and report invalid coefficients, improving error handling and user feedback. - Updated comments to clarify the importance of coefficient normalization in the context of simulation.
- Added optional parameters `mean_dispersion_slope` and `mean_dispersion_intercept` to allow users to specify the slope and intercept for the mean-dispersion association, enhancing flexibility in simulations. - Updated the `simulate_data` function to reflect changes in parameter defaults, setting `variability_multiplier` to 1 for consistency. - Enhanced documentation to include new parameters and their usage, ensuring clarity for users. - Adjusted the Stan model to accommodate the new mean-dispersion parameters, improving simulation accuracy.
- Changed default `variability_multiplier` from 5 to 1 in `sccomp_simulate()` and `simulate_data()`, preserving model variability by default. - Enhanced simulation documentation for clarity on `mean_dispersion_slope` effects and updated vignette examples for consistency. - Clarified behavior of mean-dispersion association parameters in simulation, detailing their impact on intercept and factor-level variability.
There was a problem hiding this comment.
Pull request overview
This pull request improves the simulation functionality in the sccomp package by introducing a new sccomp_simulate() function with enhanced capabilities, deprecating the old simulate_data() function, and providing comprehensive documentation and tests.
Changes:
- Introduced new
sccomp_simulate()function with improved API design supporting separate coefficient tables, optional mean-dispersion association parameters, and better handling of new data scenarios - Changed default
variability_multiplierfrom 5 to 1 to preserve fitted model variability by default - Added comprehensive test suite with 11 test cases covering various simulation scenarios
- Updated Stan model to support user-provided coefficients and mean-dispersion parameters
- Created extensive vignette with practical examples and use cases
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| R/simulate_data.R | Major refactoring introducing sccomp_simulate() with new API; deprecated simulate_data() wrapper |
| inst/stan/glm_multi_beta_binomial_simulate_data.stan | Enhanced Stan model with user-provided coefficients and mean-dispersion parameters support |
| tests/testthat/test-simulate_data.R | New comprehensive test suite with 407 lines covering 11 different scenarios |
| man/sccomp_simulate.Rd | New documentation for sccomp_simulate() function |
| man/simulate_data.Rd | Updated to indicate deprecation |
| dev/sccomp_simulate.qmd | New 859-line vignette with detailed examples and use cases |
| R/utilities.R | Added normalize_sum_to_zero_params() utility function (not currently used) |
| inst/NEWS.rd | Release notes documenting simulation improvements |
| NAMESPACE | Updated exports for new function |
| DESCRIPTION | Version bump to 2.1.25 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| \name{NEWS} | ||
| \title{News for Package \pkg{sccomp}} | ||
|
|
||
| \section{News in version 2.1.24}{ |
There was a problem hiding this comment.
The DESCRIPTION file shows version 2.1.25, but the NEWS.rd file documents changes for version 2.1.26. These version numbers should match to avoid confusion. Either the DESCRIPTION version should be bumped to 2.1.26, or the NEWS section should be for version 2.1.25.
| \section{News in version 2.1.24}{ | |
| \section{News in version 2.1.25}{ |
| mean_dispersion_slope = mean_dispersion_slope, | ||
| mean_dispersion_intercept = mean_dispersion_intercept, |
There was a problem hiding this comment.
The deprecated simulate_data() function references mean_dispersion_slope and mean_dispersion_intercept parameters on lines 730-731, but these parameters are not defined in the function signature. This will cause an error when users call simulate_data(). These parameters should either be added to the function signature or removed from the call to sccomp_simulate().
There was a problem hiding this comment.
removed from the call to sccomp_simulate()
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Updated unit tests to check for the presence of the `cache_stan_model` parameter in `sccomp_simulate`, reflecting the recent function introduction. - Maintained checks for the deprecated `simulate_data` function to ensure backward compatibility. - Verified that the default value of `cache_stan_model` is set correctly across relevant functions.
No description provided.