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

Issue 15: add VAR and season specific intercept #21

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

kaitejohnson
Copy link
Collaborator

@kaitejohnson kaitejohnson commented Feb 25, 2025

This PR addresses #15. It is still a WIP, though hoping to get something merged for the forecast submissions for next Tuesday.

Here are some example forecasts and other outputs from this model.
raw_data
Sigma
a_matrix
forecast_draws
quantiled_forecasts

My next steps are to make sure the model in the stan code is consistent with the maths written here, as I have gotten myself confused in the past few days...

@seabbs seabbs marked this pull request as draft February 25, 2025 15:44
Copy link
Collaborator

@seabbs seabbs left a comment

Choose a reason for hiding this comment

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

I don't really have a basis for comparison but this seems fine.

Note that the use of a log link means that the season/location specific intercept becomes a multiplier of the seasonal variation I believe

@kaitejohnson
Copy link
Collaborator Author

I tried back testing on January 21st, just to see if the forecasts looked reasonable, and they are quite dispersed (as they are above for the 2025-02-18 example, as well).

I think we probably need to interrogate the priors a bit more (as you mentioned, I think my intercept prior might be wrong, though I don't think that is what would be driving this dispersion here).

Uploading forecast_draws.png…

@kaitejohnson
Copy link
Collaborator Author

quantiled_forecasts
raw_data

@seabbs
Copy link
Collaborator

seabbs commented Mar 4, 2025

I think we probably need to interrogate the priors a bit more (as you mentioned, I think my intercept prior might be wrong, though I don't think that is what would be driving this dispersion here).

My assumption is that its model misspecification due to not allowing for seasonal changes

Also given that data point that forecast does not seem totally wild to me

@seabbs
Copy link
Collaborator

seabbs commented Mar 4, 2025

I think part of the issue here could be having a seasonal intercept at all whilst still having just the one VAR across all seasons. The motivation would be if there is a clear lack of continuity between different seasons that goes beyond the usual variance. Having a look at your plot above this doesn't seem to be the case but its hard to be clear.

I think you would need this intercept if you were going to start treating seasons as independent (i.e. time starts at the beginning of the season for the AR process ) or if yes there is a massive between season jump that is outside the expected AR variance.

I would potentially test each feature a bit on their own before bringing them together

@@ -105,15 +111,14 @@ if (config$targets[index] == "ILI ED visits" && config$regions_to_fit[index] ==
# Shared smooth of day of week
s(day_of_week, k = 3),
Copy link
Collaborator

Choose a reason for hiding this comment

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

a note for another time but are you gam.checking k?

@@ -92,6 +97,7 @@ if (config$targets[index] == "ILI ED visits" && config$regions_to_fit[index] ==
trend_formula = ~
# Hierarchical intercepts capture variation in average count
s(trend, bs = "re") +
s(trend, season, bs = "re") +
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this introduce an intercept for trend on its own (i.e is it a duplicate of line 99). I find the syntax very confusing personally. The way to check is to look at the output I think

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