Comments (3)
Thanks @seabbs, the example worked without errors. Will let you know in case I have more issue. Also thanks for tweaking the code!
from epinowcast.
Thanks Johannes, this certainly seems like a bug related to the recent issues with cmdstan initialisation.
I'll investigate the reprex (thank you) and circle back.
from epinowcast.
Yup this was another initialisation issue. Thank you for reporting.
I slightly tweaked your code to make it a little simpler (I don't think your reporting model was very sensible in most settings I can imagine as it had a group-specific hazard intercept on top of group-specific log normal delay)).
# Load data.table and ggplot2
library(data.table)
# Use 2 cores
options(mc.cores = 2)
# Load and filter germany hospitalisations
nat_germany_hosp <-
germany_covid19_hosp[location == "DE"][age_group %in% c("00+", "80+")]
nat_germany_hosp <- enw_filter_report_dates(
nat_germany_hosp,
latest_date = "2021-10-01"
)
# Make sure observations are complete
nat_germany_hosp <- enw_complete_dates(
nat_germany_hosp,
by = c("location", "age_group")
)
# Make a retrospective dataset
retro_nat_germany <- enw_filter_report_dates(
nat_germany_hosp,
remove_days = 40
)
retro_nat_germany <- enw_filter_reference_dates(
retro_nat_germany,
include_days = 40
)
# Get latest observations for the same time period
latest_obs <- enw_latest_data(nat_germany_hosp)
latest_obs <- enw_filter_reference_dates(
latest_obs,
remove_days = 40, include_days = 20
)
# Preprocess observations (note this maximum delay is likely too short)
pobs <- enw_preprocess_data(retro_nat_germany, by = "age_group", max_delay = 20)
# set reference time indexed reporting process model
reference_module <- enw_reference(
~ 1 + (1 | .group), distribution = "lognormal", data = pobs
)
# set reporting time indexed reporting process model
report_module <- enw_report(~ 1, data = pobs)
# set expectation module
expectation_module <- enw_expectation(
~ rw(week, by = .group),
observation = ~ (1 | day_of_week:.group),
data = pobs
)
# Fit the nowcast model and produce a nowcast
# Note that we have reduced samples for this example to reduce runtimes
nowcast <- epinowcast(pobs,
reference = reference_module,
report = report_module,
expectation = expectation_module,
fit = enw_fit_opts(
save_warmup = FALSE, pp = TRUE,
chains = 2, iter_warmup = 500, iter_sampling = 500,
max_treedepth = 12, adapt_delta = 0.95
)
)
plot(nowcast, latest_obs) + facet_wrap(vars(age_group), scales = "free")
The code for this is on seabbs/seabbs/issue281
- just assembling some unit tests for this now and then will PR.
FYI if you use multi-threading on this model you should get a linear speed up. Also the performance of daily random walks leaves a lot to be desired. Happy to hear suggests for improvements but ultimately likely needs a lot of profiling to work out how to do better.
from epinowcast.
Related Issues (20)
- Comments on `germany-age-stratified-nowcasting.Rmd` HOT 3
- Comments on `README.Rmd` HOT 3
- Schematic for `model.Rmd` HOT 5
- Check documentation of supported input types and standardise
- Check documentation of outputs
- Split `model.Rmd` vignette into separate vignettes
- Switch to using cmdstanr to expose Stan functions to R HOT 2
- README equation rendering HOT 8
- README citation rendering
- Model initialisation issues due to a cmdstan update
- Model compilation failing on Windows in CI HOT 2
- Improve documentation of discrete distributions HOT 3
- Improve documentation for enw_preprocess_data HOT 2
- Add support for a gamma Poisson mixture observation model
- Add support for a normal observation model
- Add support for using NA to indicate skipping a term from the likelihood
- Explore the use of the stan transformation functions HOT 1
- Improve discretisation
- Getting help with stan vignette
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from epinowcast.