Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider supporting cumsum, cumprod, dplyr::cummean, dplyr::lag, dplyr::lead, diff, convolve, growth_rate in epi_slide_opt #619

Open
brookslogan opened this issue Mar 3, 2025 · 0 comments

Comments

@brookslogan
Copy link
Contributor

brookslogan commented Mar 3, 2025

cumsum, cumprod, dplyr::cummean would have to be used with (implicit?) .window_size = Inf, .align = "right". dplyr::{lag, lead} would need more logic. diff would need even more logic. convolve should use "filter" and may or may not require extra logic. growth_rate might just fit in, need to check.

Pro:

  • cumsum seems like it might be relatively common (calculating cumulative case counts by epikey) and better-recognized than the data.table::frollsum(adaptive = TRUE) alternative
  • cumsum, cumprod, dplyr::cummean are likely faster than the more general data.table::froll{mean,sum}(adaptive = TRUE)
  • We currently don't have lag & lead functionality directly in epiprocess
  • We've been asked about availability of convolution operations. (Though maybe this means it should be a separate function.)

Counter concerns:

  • Window size logic required might be messy.
  • cumsum's already possible via data.table alternative.
  • cumprod seems unlikely to be used except for probabilities, in which case it should probably be avoided & cumsum on log probs should be used so it will work on longer time series without becoming zero.
  • Lag and lead would then be filtered to be in input epikeytimes, which may or may not be what is wanted. More control and faster results could be obtained by moving & adding knobs to epipredict:::epi_shift.
@brookslogan brookslogan changed the title Consider supporting cumsum, cumprod, dplyr::cummean, dplyr::lag, dplyr::lead in epi_slide_opt Consider supporting cumsum, cumprod, dplyr::cummean, dplyr::lag, dplyr::lead, diff in epi_slide_opt Mar 10, 2025
@brookslogan brookslogan changed the title Consider supporting cumsum, cumprod, dplyr::cummean, dplyr::lag, dplyr::lead, diff in epi_slide_opt Consider supporting cumsum, cumprod, dplyr::cummean, dplyr::lag, dplyr::lead, diff, convolve in epi_slide_opt Mar 13, 2025
@brookslogan brookslogan changed the title Consider supporting cumsum, cumprod, dplyr::cummean, dplyr::lag, dplyr::lead, diff, convolve in epi_slide_opt Consider supporting cumsum, cumprod, dplyr::cummean, dplyr::lag, dplyr::lead, diff, convolve, growth_rate in epi_slide_opt Mar 13, 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

No branches or pull requests

1 participant