-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
OOPObject oriented programmingObject oriented programming
Description
Background
The dubicube package currently provides functions that operate on processed_cube objects from other packages. All functions return data frames representing bootstrapped results, confidence intervals, or effect classifications.
Currently:
- There is no standard object structure for these outputs.
- Users must inspect raw data frames to understand results.
- Method dispatch (e.g.,
print,summary,plot) is not available.
Goal: Introduce S3 classes for dubicube outputs to improve clarity, usability, and method dispatch.
Proposed S3 Classes
| Function / Output | Proposed S3 Class | Fields / Structure | Methods |
|---|---|---|---|
cross_validate_cube() |
cube_cv |
dataframe with LOO or k-fold results, metadata | print, summary, plot |
bootstrap_cube() |
cube_bootstrap, boot_list (when using boot::boot?) |
bootstrap replicates, statistic, metadata | print, summary, plot |
calculate_bootstrap_ci() |
bootstrap_ci |
statistic, CI bounds, method, metadata | print, summary, plot |
add_effect_classification() |
effect_classification |
original data frame + effect class column | print, summary, plot |
calculate_acceleration() |
acceleration_result |
dataframe with acceleration statistics | print, summary, plot |
Implementation Plan
-
Define S3 Constructors
-
Example:
new_cube_bootstrap <- function(df, statistic, n_boot, ...) { structure(list(data = df, statistic = statistic, n_boot = n_boot, ...), class = "cube_bootstrap") }
-
-
Implement S3 Methods
print()→ concise summary of main results.summary()→ high-level statistics and CI coverage.plot()→ visualization of bootstrap distributions, effect classes, acceleration trends, etc.
-
Update Functions to Return S3 Objects
- Wrap data frame outputs in the appropriate S3 constructor.
- Keep raw data frames accessible (e.g.,
as.data.frame()method) for compatibility.
-
Add Helper Functions
is_cube_bootstrap(),is_bootstrap_ci(), etc., for input validation.- Optional coercion methods:
as.data.frame.cube_bootstrap()
-
Testing
- Unit tests to ensure correct class assignment.
- Validate method dispatch (
print,summary,plot).
Next Steps
- Create S3 constructors for each result type.
- Implement
print(),summary(), andplot()methods. - Update dubicube functions to return S3 objects.
- Add unit tests for class handling and method dispatch.
- Update documentation and vignettes.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
OOPObject oriented programmingObject oriented programming