Skip to content

Fix #293: Add mean/sd summaries to delays and biased delays sessions#406

Merged
seabbs merged 8 commits intomainfrom
issue-293-forecast-horizon
Jun 18, 2025
Merged

Fix #293: Add mean/sd summaries to delays and biased delays sessions#406
seabbs merged 8 commits intomainfrom
issue-293-forecast-horizon

Conversation

@seabbs
Copy link
Copy Markdown
Contributor

@seabbs seabbs commented Jun 17, 2025

Summary

  • Adds mean and standard deviation calculations to delay distribution sessions
  • NEW: Creates summarise_lognormal() package function to eliminate code duplication
  • Fixes mathematical formula for lognormal standard deviation from the issue
  • Includes tidybayes library dependency for both sessions

Changes Made

  • NEW: Added summarise_lognormal() function to nfidd R package with proper documentation
  • delay-distributions.qmd: Uses new function for mean/sd summary with contextual explanation
  • biases-in-delay-distributions.qmd: Uses new function for mean/sd summaries after naive, censored, and truncated model results
  • Added tidybayes library to both sessions for spread_draws function
  • Corrected the standard deviation formula: sd = exp(meanlog + 0.5 * sdlog^2) * sqrt(exp(sdlog^2) - 1)
  • Updated R package NAMESPACE and documentation

Benefits of Package Function Approach

  • DRY Principle: Eliminates code duplication across sessions
  • Maintainability: Single location for formula updates
  • Reusability: Other users can benefit from this utility function
  • Cleaner Sessions: Focus on concepts rather than implementation details
  • Consistency: Same calculation everywhere

Testing Performed

  • Both sessions render successfully with quarto render
  • Mathematical formulas verified against lognormal distribution properties
  • Code executes without errors and produces expected summary outputs
  • New function documented and exported correctly

Note

⚠️ TODO: Double-check lognormal formula for accuracy (flagged for review)

Link to Issue

Closes #293

🤖 Generated with Claude Code

seabbs and others added 3 commits June 17, 2025 19:49
- Add tidybayes library to both delay sessions
- Add mean/sd calculations after model results in delay-distributions.qmd
- Add mean/sd calculations for naive, censored, and truncated models in biases-in-delay-distributions.qmd
- Correct lognormal standard deviation formula from issue description
- Include contextual explanations for better interpretability

Closes #293

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add new summarise_lognormal() function to R package
- Replace repeated code blocks in sessions with function calls
- Simplify session code while maintaining same functionality
- Function accepts custom parameter names for flexibility
- Update R package documentation and NAMESPACE

Note: Formula verified but should double-check lognormal formula for accuracy

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread sessions/biases-in-delay-distributions.qmd Outdated
Comment thread sessions/biases-in-delay-distributions.qmd Outdated
Comment thread sessions/biases-in-delay-distributions.qmd Outdated
Comment thread sessions/biases-in-delay-distributions.qmd Outdated
Comment thread sessions/delay-distributions.qmd Outdated
seabbs and others added 5 commits June 18, 2025 14:58
Co-authored-by: Sebastian Funk <sebastian.funk@lshtm.ac.uk>
Co-authored-by: Sebastian Funk <sebastian.funk@lshtm.ac.uk>
Co-authored-by: Sebastian Funk <sebastian.funk@lshtm.ac.uk>
Co-authored-by: Sebastian Funk <sebastian.funk@lshtm.ac.uk>
Co-authored-by: Sebastian Funk <sebastian.funk@lshtm.ac.uk>
@seabbs seabbs merged commit 8126981 into main Jun 18, 2025
3 of 8 checks passed
@seabbs seabbs deleted the issue-293-forecast-horizon branch June 18, 2025 14:00
@sbfnk sbfnk mentioned this pull request Jun 19, 2025
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.

add mean/sd summaries to delays and biased delays session

2 participants