covid19br / nowcaster Goto Github PK
View Code? Open in Web Editor NEWRepository for a nowcasting by INLA
Home Page: https://covid19br.github.io/nowcaster
License: GNU General Public License v3.0
Repository for a nowcasting by INLA
Home Page: https://covid19br.github.io/nowcaster
License: GNU General Public License v3.0
Through a simple linear model adjusted to the trajectories, we can infer the tendency of the epidemic curve, to do so we can construct functions that take the posteriors output from the main function nowcasting_inla
and adjust the linear model and return the slope of the trajectories, to give a more quantitative tendency inference:
There is a bug on the use of parameter K. When the last week is incomplete and K = 0 the last week to correct delay is the last complete week. But when K>0, it should forecast the current (and incomplete) week and the following K-1 weeks, but it seems to forecast K weeks beyond the current. As as example, when K=1, it should forecast the current (and incomplete) week but it forecasts two weeks ahead, the current one + 1.
data(sragBH)
sragBH20 <- sragBH %>%
filter(
# Excluding typing date before symptoms onset
DT_SIN_PRI <= DT_DIGITA,
# Excluding no typing date
!is.na(DT_DIGITA),
# cases reported in 2020
year(DT_DIGITA) == 2020
)
max(sragBH20$DT_DIGITA)
weekdays(max(sragBH20$DT_DIGITA))
epiweek(max(sragBH20$DT_DIGITA))
# Incomplete week (recording ends on Thursday)
# Nowcasting ignores an incomplete week (OK)
nowk0 = nowcasting_inla(dataset = sragBH20,
date_onset = DT_SIN_PRI,
date_report = DT_DIGITA,
silent = T)
nowk0$total %>%
mutate(
epiweek = epiweek(dt_event)
) %>% tail()
# Week to forecast: week 53 only, but it forecast weeks 53/20 and 1/21
nowk1 = nowcasting_inla(dataset = sragBH20,
date_onset = DT_SIN_PRI,
date_report = DT_DIGITA,
K = 1,
silent = T)
nowk1$total %>%
mutate(
epiweek = epiweek(dt_event)
) %>% tail()
# Weeks to forecast: week 53 and 1, but it forecast weeks 53/20, 1 and 2/21
nowk2 = nowcasting_inla(dataset = sragBH20,
date_onset = DT_SIN_PRI,
date_report = DT_DIGITA,
K = 2,
silent = T)
nowk2$total %>%
mutate(
epiweek = epiweek(dt_event)
) %>% tail()
We need on this line to verify which are date formats, the actual problem it is the onset dates are moved to the last complete day of the week .
Maybe a solution:
turn back the dates to its original format, which it is the inverser of the formula in dados_w()
Create new internal functions for nowcasting with and without spatial structured data, nowcasting_spatial
for spatialy structured data and the existing nowcasting_age
& nowcasting_no_age
for non-spatial structured data
nowcasting_spatial
created and implementedHessian test is constructed to avoid problems when the INLA solver stack in negative eigenvalues, to avoid it we can work on the length iteration steps. The test can be implemented through a while
test until it reach a certain amount of tries. Follows a schematic test to be put on the nowcasting_age
and nowcasting_no_age
functions:
hess.min <- -1
h.value <- 0.01
h.trials <- 0.001
trials <- 0
while (hess.min <= 0 & trials < 50){
# Running the Negative Binomial model in INLA
output0 <- inla(model, family = "nbinomial", data = dados.age,
control.predictor = list(link = 1, compute = T),
control.compute = list(config = T, waic=F, dic=F, openmp.strategy='huge'),
control.family = list(
hyper = list("theta" = list(prior = "loggamma",
param = c(0.001, 0.001))
)
),
num.threads = 6,
control.inla = list(h = h.value),
...
)
hess.start <- which(output0$logfile == 'Eigenvalues of the Hessian')
hess.min <- min(as.numeric(output0$logfile[(hess.start+1):(hess.start+3)]))
h.value <- h.trials + 0.001
h.trials <- h.value
trials <- trials + 1
}
@rafalopespx nowcasting_age
is the workhorse of the package, needs to be more friendly user
Implement a trajectory flag on nowcasting_inla
to give back the option trajectory devolution
Posterior sampling parameter implementation, through the parameter n
on inla.posterior
Require INLA with the NAMESPACE and Warning if it is not installed:
Line 116 in 7b71c50
Need to be changed to have all distinct dates
To guarantee a well written documentation and understandable articles, we have to review the articles presented in the site of the package:
Manage to make pkgdown site version working
To build more cleaverly the package, without problems when calling nowcasting_inla()
, create another functions that will by called by nowcasting_inla
to make nowcasting without stratifying and make nowcasting with clustering specified data.
Tentative names, nowcasting_no_stratum()
and nowcasting_cluster()
, add the parameters to call those functions on nowcasting_inla()
, these new functions will have a structure similar to nowcasting_age()
๐๐ฝ I maintain the cran checks badges. Please change to the new cran checks badge URL (e.g., https://badges.cranchecks.info/worst/dplyr.svg
). Old badges at (e.g. https://cranchecks.info/badges/worst/dplyr
) will be unavailable as of Jan 1st 2023.
Create an article performing a forecasting using the parameter K > 0
Stabilize the Imports for the package, now is import by the export specification on the NAMESPACE:
Add a column with the observed number of cases in the nowcaster outputs.
> aaa$total
# A tibble: 15 ร 7
Time dt_event Median LI LS LIb LSb
<int> <date> <dbl> <dbl> <dbl> <dbl> <dbl>
1 17 2019-10-26 154 154 154 154 154
2 18 2019-11-02 173 173 173 173 173
Need to check the last date in the dataset and the last date in the nowcast estimates. It seems they don't match properly.
Use of native pipe into pipelines |>
Implement and test a model with covariate of tweets counts and google trends searches on the main function nowcasting_inla
:
nowcasting_covariates()
nowcasting_inla
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.