cmu-delphi / epiforecast-R

R package to implement and visualize several epidemiological forecasting methods.
GNU General Public License v2.0
21 stars 5 forks source link

Weights of twkde.markovian.sim are all identical and equals one #6

Closed siddharthgarg89 closed 4 years ago

siddharthgarg89 commented 4 years ago

Below is the code snippet that we were running in order to get the associated weights:

full.dat = fetchEpidataFullDat("fluview", area.name, "wili",min.points.in.season = 52L,first.week.of.season = 31L,cache.file.prefix=sprintf("fluview_%s_fetch", area.name))
full.dat <- full.dat[names(full.dat)!="S2009"]
sim = twkde.markovian.sim(full.dat, max.n.sims=100)
sim$weights

This was the output that we obtained:

> sim$weights

[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[51] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

So,the weights are all same and are unity which were expected to be different.

Also, I have attached the input file that contains "full.dat" for your reference:

full_dat.xlsx

brookslogan commented 4 years ago

This behavior is actually intended. In fact, most of the forecasting methods in this package will output equally-weighted samples, as they more directly model the conditional distribution Future | Past=past. This is different from, e.g., the Empirical Bayes method, which does something similar to sampling from the joint distribution (Past,Future) and weighting based on the observation Past=past (the actual algorithm uses an importance sampling technique which is a little more complicated than this).