Skip to content

Rtmb delay convolution#116

Open
bbolker wants to merge 16 commits intomainfrom
RTMB_delay_convolution
Open

Rtmb delay convolution#116
bbolker wants to merge 16 commits intomainfrom
RTMB_delay_convolution

Conversation

@bbolker
Copy link
Collaborator

@bbolker bbolker commented Jun 16, 2025

this is a first draft of machinery for handling case reporting delays via mgcv smooth machinery exported to RTMB.

The summary document is here

Conclusions so far:

  • for a very simple case, RTMB-convolve (with known delay distribution) with an extremely variable delay distribution appears to outperform a shifted GAM model (but I haven't tried to quantify this yet with deviance/RMSE/whatever ...)

Obvious challenges/to do:

  • allow use of more complicated smooth terms (factor smooths etc etc) [will probably break the glmmTMB machinery this is based on]
  • computational cost? (can't easily switch to bam-style optimization ...)
  • quantify performance improvement; more realistic examples?

@codecov
Copy link

codecov bot commented Jun 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bbolker
Copy link
Collaborator Author

bbolker commented Jun 16, 2025

Lots of chaff here (linting, adding package dependencies, renv() out of date [FWIW I find renv() awkward to use because there is some odd stuff with conflicting Rprofiles, e.g. see here, but will fight with this stuff if it is important for this workflow ...]

@zsusswein

This comment has been minimized.

@bbolker
Copy link
Collaborator Author

bbolker commented Jun 16, 2025

Is there a standard linter I should be using/other coding standards? This document says I should look in the README for info about linters etc. but I don't see anything (again, not trying to make extra work for you — just trying to fit in)

Never mind, figured it out.

Copy link
Collaborator

@zsusswein zsusswein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Ben -- this is fabulous.

I'm sorry I didn't get to this sooner. I left a few thoughts below on my way to the airport, but I didn't give it as thorough a read as it deserves. My apologies. I noted a few things I was interested in, but don't let those disrupt the direction you're going here.

I tagged my colleague Sam for your question about citations on delays. I'm hoping he'll have something top-of-mind.

I'm approving so as to not hold you up in my absence. Sorry about the CI pain! For future reference, there's a justfile you can use to run the checks locally and auto-format.


## To do

* is there intuition/math for why taking the convolution into account
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can give a more thorough look when I'm back next week but I think @SamuelBrand1 might be the person to ask? Sam does anything spring to mind?


Will want to compare true_rt, true_incident_cases
also, maybe, true growth rate? (maybe adjust code to
return true_Rt and true_rt/true_growth? Back-calculating
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe predict.RtGam should do it for you. You could also just difference the linear predictor with no shift?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't differencing the linear predictor give me (an approximation to) growth rate ("little-r"), not Rt? Or maybe I'm missing something ...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry was unclear -- I meant for little-r. predict.RtGam should give you both r and R.

* will need extra machinery for prediction
* computational cost?
* fragility?
* end effects?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To this point, I'd be interested in seeing the differences in Rt here -- maybe across a range of GIs?

It's probably not reasonable to make a general statement, but if you think it's feasible I'd be interested in the impact on Rt from using on one approach vs the other.

Clearly there will be a bias. When is the bias most extreme (I.e. is it Rt peak or infection peak)?

start = list(theta = 3),
delay_pmf = delay_pmf
)
a3 <- augment(m3)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not totally following this augment() call. I can see it's adding some stuff from the functions file?

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.

2 participants