Fix Issue #8: Transform continuous outcome estimates back to original scale
๐ฏ Overview
This PR addresses Issue #8 by implementing continuous outcome rescaling to transform variable importance estimates from the [0,1] scale back to the original outcome scale.
๐ง Problem
Variable importance estimates for continuous outcomes were being reported on the [0,1] scale instead of the original outcome scale, making results difficult to interpret. For example, if the original outcome ranged from 10-50, estimates were being reported as values between 0-1 rather than meaningful values in the 10-50 range.
๐ก Solution
Core Changes
Modified estimate_pooled_results():
- Added
Qboundsandmap_to_ystarparameters to accept outcome bounds information - Implemented transformation logic to convert theta estimates from [0,1] scale back to original scale
- Added proper error handling for the transformation process
Updated vim_numerics() and vim_factors():
- Modified to pass
Qboundsandmap_to_ystarparameters toestimate_pooled_results() - Ensures bounds information is available for the rescaling transformation
- Maintains backward compatibility for binary outcomes
Technical Implementation
The rescaling uses the formula:
# Transform from [0,1] scale back to original scale
rescaled_estimate = estimate * (upper_bound - lower_bound) + lower_bound
Where upper_bound and lower_bound are the original outcome variable's range.
๐ Files Changed
R/estimate_pooled_results.R- Core rescaling logicR/vim-factors.R- Pass bounds for factor variable analysisR/vim-numerics.R- Pass bounds for numeric variable analysistests/testthat/test-continuous-outcome-scale.R- Comprehensive test suiteNEWS.md- Documentation of the fix
๐งช Testing
Added comprehensive test suite that verifies:
- โ Continuous outcomes are rescaled to original scale
- โ Binary outcomes continue to work correctly
- โ Edge cases and error conditions are handled
- โ ๏ธ Note: Tests currently fail due to VIM calculation issues that need further investigation
โ ๏ธ Known Issues
The continuous outcome rescaling logic is implemented but currently has test failures where vim$results_all is NULL. This suggests the rescaling changes may be interfering with VIM calculations and requires additional debugging to ensure the transformation doesn't break the core functionality.
๐ฏ Next Steps
- Debug why VIM calculations are failing with the rescaling changes
- Ensure the transformation preserves all existing functionality
- Validate that rescaled estimates are mathematically correct
๐ Related
- Fixes #8
- Addresses continuous outcome interpretation issues
- Maintains backward compatibility with binary outcomes