-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Current and expected behavior
Median frequencies from MCMC estimate do not always sum to 100%, but the mean frequencies should.
For example, the following figure shows recent B/Vic total frequencies by forecast date and location using posterior medians:
Then, when we calculate B/Vic total frequencies by forecast date and location using posterior means, we get the following:
Possible solution
Options include:
- Change the local
run-modelscript to calculate the mean across the posterior distributions there - Change the workflow to post-process the posterior JSON exported by
run-modelto generate mean frequencies - Change evofr to allow the user to specify an alternate point estimator to median in the
get_sites_variants_tidyfunction or add mean as an estimator along with the existing quantile estimation.
The last option is most appealing since it doesn't require us to duplicate logic for looping over the posterior samples and it's backward compatible for forecasts-ncov and any other downstream uses of evofr.
Even if we replace the "median" entries in the JSON with "mean" (or add a new "mean" entry), the evofr-viz library we use to plot frequencies hardcodes a reference to the "median" entry. The parseModelData function needs a way to know which point estimate to use from the available ps values in the model JSON. The simplest way to pass that information may be in the model JSON's metadata, following the existing pattern of specifying variant colors in the metadata. For example, we could add an optional ps_point_estimate_key to the metadata which refers to the key in the available ps values to use as the point estimate. This change would be backward compatible, too, if the default behavior is to use the "median".
If we choose to modify the model JSON, then we need to add an argument to evofr's get_sites_variants_tidy function to allow the calling code to set the ps_point_estimate_key in the metadata.
The plan would involve the following PRs: