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

Feature missing reference dates #64

Closed
wants to merge 190 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
7477b32
update pre-commit yaml
seabbs Jan 29, 2022
16506c4
add outline for formula passer
seabbs Jan 29, 2022
cd274a5
add first pass at formula interface tooling
seabbs Jan 29, 2022
2b4ea43
merge changes from main
seabbs Apr 14, 2022
f6e2df3
Remove reduce_sum parallelization
adrian-lison May 13, 2022
d288fe2
Add observations with missing reference date
adrian-lison May 13, 2022
6cdf3f2
Add alpha vector
adrian-lison May 15, 2022
6ca4657
Implement random walk prior on logit alpha
adrian-lison May 16, 2022
0e43ede
Simplify non-parallelized obs_lpmf
adrian-lison May 16, 2022
c3350ab
Make alpha doc more generic
adrian-lison May 16, 2022
2864eee
Add first draft of likelihood computation for missing reference dates
adrian-lison May 16, 2022
fa415e9
Implement slicing of likelihood for obs_miss from 1+dmax onwards
adrian-lison May 16, 2022
104efd6
Bugfix obs_lmpf and improve formatting
adrian-lison May 17, 2022
4539e48
Extend generated quantities to cases with missing reference date
adrian-lison May 17, 2022
0db6ce1
Change pp_inf_obs_miss_rep assignment to loop
adrian-lison May 18, 2022
17484d0
Fix typo
adrian-lison Jun 13, 2022
87e57e8
Catch bug if data.table contains column "group"
adrian-lison Jun 13, 2022
bdd2fba
Preprocess missing reference dates
adrian-lison Jun 13, 2022
2343ee9
Add automatic completion of missing reporting dates per group and ref…
adrian-lison Jun 13, 2022
d47c510
Change structure and fix assignment
adrian-lison Jun 13, 2022
4a0b647
Change date range for missing reference dates
adrian-lison Jun 13, 2022
41187e5
Add obs_miss to stan_data_list
adrian-lison Jun 13, 2022
dfb1297
update from main
seabbs Jun 15, 2022
d70e559
plan out formula interface in more detail
seabbs Jun 15, 2022
4570a8f
streamline final construction
seabbs Jun 15, 2022
61c351e
filter rw
seabbs Jun 15, 2022
8b68665
Change code comments
adrian-lison Jun 16, 2022
4e43eb7
Move completion to separate function, account for max_date
adrian-lison Jun 16, 2022
275efc8
Adapt obs_miss length from rd to t
adrian-lison Jun 16, 2022
08b8b1f
Correct alpha and obs in stan model
adrian-lison Jun 16, 2022
8add91b
Add priors for alpha
adrian-lison Jun 16, 2022
bd449e7
add more detail to outline
seabbs Jun 16, 2022
13759ff
Add support for missing reference dates to enw_retrospective_data
adrian-lison Jun 21, 2022
724f61c
Merge branch 'main' into feature-add-rw-re-formula-int
seabbs Jun 21, 2022
2e94e01
XMerge branch 'main' into feature-add-rw-re-formula-int
seabbs Jun 21, 2022
58b7da2
morework on formula interface
seabbs Jun 21, 2022
383fbf7
working construcotr for random walks
seabbs Jun 22, 2022
6cf52ec
add partial random effects structure
seabbs Jun 22, 2022
40a0309
prototype random effects constructor
seabbs Jun 22, 2022
73460c9
add comments for formula
seabbs Jun 22, 2022
e011eb9
more commenting
seabbs Jun 22, 2022
8cfb703
put formula pieces together
seabbs Jun 23, 2022
ac809ac
Fix generated quantities and add code doc
adrian-lison Jun 24, 2022
a48ae0a
Shorten loglik missing array
adrian-lison Jun 24, 2022
0d0e13a
add random walk term extraction and effects
seabbs Jun 24, 2022
74a2572
candidate formula function implemented
seabbs Jun 24, 2022
9f2e8cd
update readme to use formula interface
seabbs Jun 24, 2022
6bf72e1
refresh documentation
seabbs Jun 24, 2022
187fb15
add skeleton documentation
seabbs Jun 24, 2022
ba8d135
update README
seabbs Jun 24, 2022
eeb6d8c
fix no report model edge case
seabbs Jun 25, 2022
67df447
fix edge case with (Intercept) in random effect matrix
seabbs Jun 25, 2022
354edd0
implement case studies using formulas and fix edge cases
seabbs Jun 25, 2022
73e0d58
add note about reduce samples and iterations to vignette
seabbs Jun 25, 2022
43fc3e9
reduce samples used in README
seabbs Jun 25, 2022
f0fe7b4
add documentation for formula parsers
seabbs Jun 27, 2022
7d8d83d
add parse_formula docs
seabbs Jun 27, 2022
6bc72d2
add parse_formula docs
seabbs Jun 27, 2022
201f756
Merge branch 'feature-move-nb-to-log' into feature-add-rw-re-formula-int
seabbs Jun 27, 2022
07bfcb1
add documentation for rw and construct_rw
seabbs Jun 27, 2022
dbf458d
update pkgdown with new formula references
seabbs Jun 27, 2022
da6aed4
add random effect documentation
seabbs Jun 27, 2022
0956484
add complete formula docs + cran check
seabbs Jun 27, 2022
e395549
spell check, style, and iterate version
seabbs Jun 27, 2022
b85faa3
add codemeta
seabbs Jun 27, 2022
701a0e7
update docs and add pkg docs
seabbs Jun 27, 2022
2272b9d
add snapshot tests for enw_manual_formula
seabbs Jun 27, 2022
962cc1f
add snapshot tests for enw_formula
seabbs Jun 27, 2022
c76e9c2
update case study to use formula interface
seabbs Jun 27, 2022
832c234
Merge branch 'main' into feature-add-rw-re-formula-int
seabbs Jun 27, 2022
80211e8
Merge branch 'develop' into feature-add-rw-re-formula-int
seabbs Jun 27, 2022
b077f0a
update image tag
seabbs Jun 27, 2022
3a135da
update from develop
seabbs Jun 28, 2022
e01f76c
update example to use formula
seabbs Jun 28, 2022
9dff353
Merge pull request #27 from epiforecasts/feature-add-rw-re-formula-int
seabbs Jun 28, 2022
cbc5cc1
Use automated doc dev mode
seabbs Jun 28, 2022
28966f2
deploy docs from develop branch
seabbs Jun 28, 2022
345e71a
fix pkgdown.yaml
seabbs Jun 28, 2022
7a191da
scaffold out location for metadelay
seabbs Jun 28, 2022
6362a77
update family links for all fns
seabbs Jun 28, 2022
73aded3
model description clarifications
sbfnk Jun 29, 2022
98d247a
add support for non-factor random effects + initial delay metadatal
seabbs Jun 29, 2022
fad80a0
future-proof array declarations
sbfnk Jun 29, 2022
1e46bf9
ensure all parameters are initialised
sbfnk Jun 29, 2022
61754c3
update docs to reflect new metadata
seabbs Jun 29, 2022
60a8ef9
tests passing
seabbs Jun 29, 2022
ae8e507
add unit tests for enw_delay_metadata
seabbs Jun 29, 2022
fcb40d2
update news
seabbs Jun 29, 2022
8c1214c
refresh documentation
seabbs Jun 29, 2022
9d9ed8a
catch all optional model parameters and add @sbfnk as ctb
seabbs Jun 29, 2022
5c9b863
add snapshot unit tests of initial conditions
seabbs Jun 29, 2022
1b9e3d6
update example data
seabbs Jun 29, 2022
be24312
style and fix example
seabbs Jun 29, 2022
8571044
Merge pull request #77 from epiforecasts/init-params
seabbs Jun 29, 2022
8025afe
fix enw_construct_data docs
seabbs Jun 29, 2022
25a7057
remove non-standard folder
seabbs Jun 29, 2022
0375553
"reference" -> "occurrence"
sbfnk Jun 29, 2022
6694b41
"date" -> "time"
sbfnk Jun 29, 2022
0510e20
clarify use of enw_retrospective_data
sbfnk Jun 29, 2022
9566583
fix CRAN check
seabbs Jun 30, 2022
fa3ceb3
further CRAN check fixes
seabbs Jun 30, 2022
4e6484e
Merge pull request #80 from epiforecasts/feature-metadelay
seabbs Jun 30, 2022
f8d0714
merge changes from develop
seabbs Jun 30, 2022
cb3a249
catch more of cmdstanr only notation
seabbs Jun 30, 2022
0e741c7
update news with new changes
seabbs Jun 30, 2022
4624707
stan changes to support exponential delays
seabbs Jun 30, 2022
6390031
Merge pull request #75 from epiforecasts/fix-stan-warnigs
seabbs Jun 30, 2022
341d9ce
add R code support
seabbs Jun 30, 2022
6e27cc1
debug and review
seabbs Jun 30, 2022
e416d52
merge changes from develop
seabbs Jun 30, 2022
456f978
add news entry
seabbs Jun 30, 2022
c81960f
compatibility with rstan for exposing functions
sbfnk Jul 1, 2022
7c96a30
update variables names
sbfnk Jul 1, 2022
2f254b3
update distribution comment
seabbs Jul 4, 2022
5789bd5
fix comma dist docs
seabbs Jul 4, 2022
25c6426
fix whitespace
seabbs Jul 4, 2022
597e5cb
bump @sbfnk to author
seabbs Jul 4, 2022
8322a04
partial conversion to use dist for parametric control
seabbs Jul 4, 2022
361c13f
convert inner likelihood code to function
seabbs Jul 4, 2022
19a65df
linking model to index changes for no dist
seabbs Jul 4, 2022
5c2d9cb
linking model to index changes for no dist
seabbs Jul 4, 2022
40a30b7
add R interface
seabbs Jul 4, 2022
7bfa573
updated init tests and news in light of changes
seabbs Jul 4, 2022
10f49c6
lint package
seabbs Jul 4, 2022
37ad9b7
Merge pull request #84 from epiforecasts/feature-exp-delays
seabbs Jul 4, 2022
12e3725
move fn to not be exported and add docs
seabbs Jul 4, 2022
1a0aee3
convert expose_stan_fns to multiple fns
seabbs Jul 4, 2022
134f6b4
update news with new PR
seabbs Jul 4, 2022
9ee9bad
add tests and improve regex
seabbs Jul 4, 2022
e741f83
inverse tests
seabbs Jul 4, 2022
36c23f8
merge develop
seabbs Jul 4, 2022
14df115
Merge pull request #85 from epiforecasts/fix-expose-fns
seabbs Jul 4, 2022
3f3c0b9
add develop branch to contributing
seabbs Jul 4, 2022
68765e2
Merge pull request #86 from epiforecasts/update-contributing
seabbs Jul 4, 2022
c40224e
merge develop
seabbs Jul 4, 2022
8960181
first pass doc and code review, clarify filtering
seabbs Jul 4, 2022
a0795f2
add check dates
seabbs Jul 4, 2022
c341429
recast retrospective data construction to modular
seabbs Jul 4, 2022
5ec053d
update example
seabbs Jul 4, 2022
da7a461
add @sbfnk regex suggestion
seabbs Jul 4, 2022
62e7ae3
update news
seabbs Jul 4, 2022
9e4768d
formatting
seabbs Jul 5, 2022
10e7d0b
fix missing bracket
seabbs Jul 5, 2022
5953dd1
add an additional line of regex for matrix and vector case
seabbs Jul 5, 2022
38ab910
Merge pull request #93 from epiforecasts/bug-safer-regex
seabbs Jul 5, 2022
77be8c0
update vignettes
seabbs Jul 5, 2022
643a1da
update news and readme.Rmd
seabbs Jul 5, 2022
42c82ac
remove references to enw_retrospective_data in docs and tests
seabbs Jul 5, 2022
8855d2b
add tests for check_dates
seabbs Jul 6, 2022
ca46036
Streamline grouping parameter of complete_dates and format
adrian-lison Jul 6, 2022
7f1a325
add filtering tests
seabbs Jul 6, 2022
27fd0e7
Streamline groups
adrian-lison Jul 6, 2022
a0fe344
Replace group with .group
adrian-lison Jul 6, 2022
ddaf6f4
styleh
seabbs Jul 6, 2022
93218fd
Merge pull request #82 from epiforecasts/clarify-retrospective
seabbs Jul 6, 2022
48430cf
Merge branch 'develop' into refactor_rename_group_variable
seabbs Jul 6, 2022
b760d8f
run styling and add check fn
seabbs Jul 6, 2022
e5f1026
add tests for check_group
seabbs Jul 6, 2022
b2a6d92
add testing of model compilation
seabbs Jul 6, 2022
6d8561d
add random walk as cumulative sum
seabbs Jul 6, 2022
833bc77
add test for profiling
seabbs Jul 6, 2022
ce93c5c
lint tests
seabbs Jul 6, 2022
183526f
get rid of loop
seabbs Jul 6, 2022
ea9f85c
add news update
seabbs Jul 6, 2022
f757b14
spell check
seabbs Jul 6, 2022
d82b711
hotfix preprocessing
seabbs Jul 6, 2022
da58625
merge hotfix for preprocessing
seabbs Jul 6, 2022
34722fe
hotfix filter preprocessing
seabbs Jul 6, 2022
9183e65
hotfix scoring
seabbs Jul 6, 2022
6dca63b
merge hotfixs
seabbs Jul 6, 2022
2a18a17
test CI using cmdstan 2.29.0
seabbs Jul 6, 2022
807c1b1
Fix typos
adrian-lison Jul 7, 2022
717057d
Merge branch 'develop' into refactor_rename_group_variable
adrian-lison Jul 7, 2022
8833763
Update example data
adrian-lison Jul 7, 2022
0a5945f
Update news
adrian-lison Jul 7, 2022
f2f60b7
Fix my own typo in news
adrian-lison Jul 7, 2022
6c9ff9f
Fix grammar in news
adrian-lison Jul 7, 2022
5d1e065
make test coverage use 2.29.0
seabbs Jul 7, 2022
ba6f217
Merge pull request #103 from epiforecasts/feature-cumulative-sum-expe…
seabbs Jul 7, 2022
df67660
merge news from develop
seabbs Jul 7, 2022
3664315
save news changes this time
seabbs Jul 7, 2022
ab7add7
merge with develop
seabbs Jul 7, 2022
66e7d71
update DESCRIPTION
seabbs Jul 7, 2022
b82e0a2
replace last occurrence references
seabbs Jul 7, 2022
d47dcbf
add link to documentation to the readme
seabbs Jul 7, 2022
598f855
Merge pull request #102 from epiforecasts/refactor_rename_group_variable
adrian-lison Jul 7, 2022
b52f792
review model description
seabbs Jul 7, 2022
005b74f
add news item
seabbs Jul 7, 2022
3dc4ac0
Merge pull request #71 from epiforecasts/model-description-sbfnk-review
seabbs Jul 7, 2022
8acaf51
merge in develop
seabbs Jul 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
^vignettes/precompile.R$
^.*\.Rproj$
^\.Rproj\.user$
^codemeta\.json$
^CONTRIBUTING\.md$
^inst/make_hexsticker\.R$
^inst/make_hexsticker\.R$
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
run: |
print(list.files("C:/rtools42"))
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
cmdstanr::install_cmdstan(cores = 2)
cmdstanr::install_cmdstan(cores = 2, version = "2.29.0")
shell: Rscript {0}

- name: Session info
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/codemeta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
push:
paths:
- DESCRIPTION
- .github/workflows/codemeta.yml

name: Render codemeta
jobs:
render:
name: Render codemeta
runs-on: macOS-latest
if: "!contains(github.event.head_commit.message, 'cm-skip')"
steps:
- uses: actions/checkout@v1
- uses: r-lib/actions/setup-r@v2
- name: Install remotes
run: Rscript -e 'install.packages("remotes")'
- name: Install codemetar
run: Rscript -e 'remotes::install_local(dependencies = c("Imports", "Depends"))'
- name: Render codemeta
run: Rscript -e 'codemetar::write_codemeta()'
- name: Commit results
run: |
git commit codemeta.json -m 'Re-build codemeta.json' || echo "No changes to commit"
git push https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}.git HEAD:${{ github.ref }} || echo "No changes to commit"
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
branches: [main, master, develop]
tags: ['*']

name: pkgdown
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
run: |
print(list.files("C:/rtools42"))
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
cmdstanr::install_cmdstan(cores = 2)
cmdstanr::install_cmdstan(cores = 2, version = "2.29.0")
shell: Rscript {0}

- name: Install package
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ cache
.Rproj.user
*.Rproj
!inst/extdata/*.rds
pkgdown
pkgdown
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# R specific hooks: https://github.com/lorenzwalthert/precommit
repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.3.1
rev: v0.3.2
hooks:
- id: style-files
args: [--style_pkg=styler, --style_fun=tidyverse_style]
Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ External code contributions are extremely helpful and appreciated. Here are the

1. Prior to contribution, please propose your idea in a [new issue thread](https://github.com/epiforecasts/epinowcast/issues) so you and the reviewer can define the intent and scope of the work.
2. [Fork the repository](https://help.github.com/articles/fork-a-repo/).
3. Follow the [GitHub flow](https://guides.github.com/introduction/flow/index.html) to create a new branch, add commits, and open a pull request.
3. Follow the [GitHub flow](https://guides.github.com/introduction/flow/index.html) to create a new branch, add commits, and open a pull request.
4. Discuss your code with the reviewer in the pull request thread.
5. If everything looks good, the reviewer will merge your code into the project.

Please also follow these additional guidelines.

* We use a `develop`/ `main` workflow so please target major changes to the `develop` branch and minor changes to the `main` branch. If unclear please ask when opening the initial issue proposing the change.
* Respect the architecture and reasoning of the package. Depending on the scope of your work, you may want to read the design documents (package vignettes).
* In general we aim to use `data.table` to manipulate data. However, if this is a barrier to contributing please use tools you are familiar with and raise this in your pull request. The reviewer will then work with you to refactor your contribution or if appropriate add the dependencies you require.
* If possible, keep contributions small enough to easily review manually. It is okay to split up your work into multiple pull requests.
* Format your code according to the [tidyverse style guide](https://style.tidyverse.org/) and check your formatting with the `lint_package()` function from the [`lintr`](https://github.com/jimhester/lintr) package.
* Check code coverage with `covr::package_coverage()`. Automated tests should cover all the new or changed functionality in your pull request.
* Run overall package checks with `devtools::check()` and `goodpractice::gp()`
* Describe your contribution in the project's [`NEWS.md`](https://github.com/epiforecasts/epinowcast/blob/main/NEWS.md) file. Be sure to mention relevant GitHub issue numbers and your GitHub name as done in existing news entries.
* If you feel your contribution is substantial enough for official author or contributor status, please add yourself to the `Authors@R` field of the [`DESCRIPTION`](https://github.com/ropensci/jagstargets/blob/main/DESCRIPTION) file. In general, we consider any contribution sufficient for contributor status and several minor or a single major contribution sufficient for author status.
* If you feel your contribution is substantial enough for author or contributor status, please add yourself to the `Authors@R` field of the [`DESCRIPTION`](https://github.com/ropensci/jagstargets/blob/main/DESCRIPTION) file. In general, we consider any contribution sufficient for contributor status and several minor or a single major contributions sufficient for author status. If planning on writing a paper or similar about your package extension please note this in your contribution and feel free to suggest how you would like this to be managed.
7 changes: 6 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: epinowcast
Title: Hierarchical Nowcasting of Right Censored Epidemiological Counts
Version: 0.0.7
Version: 0.1.0.1000
Authors@R:
c(person(given = "Sam Abbott",
role = c("aut", "cre"),
Expand All @@ -11,6 +11,10 @@ Authors@R:
role = "aut",
email = "adrian.lison@bsse.ethz.ch",
comment = c(ORCID = "0000-0002-6822-8437")),
person(given = "Sebastian",
family = "Funk",
role = "aut",
email = "sebastian.funk@lshtm.ac.uk"),
person(given = "Michael",
family = "DeWitt",
role = "ctb",
Expand All @@ -35,6 +39,7 @@ Imports:
cmdstanr,
data.table,
lubridate,
lme4,
ggplot2,
posterior,
purrr,
Expand Down
15 changes: 11 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ export(enw_as_data_list)
export(enw_assign_group)
export(enw_construct_data)
export(enw_dates_to_factors)
export(enw_delay_filter)
export(enw_delay_metadata)
export(enw_design)
export(enw_effects_metadata)
export(enw_example)
export(enw_extend_date)
export(enw_filter_obs)
export(enw_filter_reference_dates)
export(enw_filter_report_dates)
export(enw_formula)
export(enw_formula_as_data_list)
export(enw_inits)
export(enw_latest_data)
export(enw_manual_formula)
export(enw_metadata)
export(enw_model)
export(enw_new_reports)
Expand All @@ -42,20 +46,19 @@ export(enw_priors_as_data_list)
export(enw_quantiles_to_long)
export(enw_reporting_triangle)
export(enw_reporting_triangle_to_long)
export(enw_retrospective_data)
export(enw_sample)
export(enw_score_nowcast)
export(enw_summarise_samples)
export(epinowcast)
export(expose_stan_fns)
export(re)
export(rw)
import(cmdstanr)
import(data.table, except = transpose)
import(ggplot2)
importFrom(cmdstanr,cmdstan_model)
importFrom(data.table,":=")
importFrom(data.table,.N)
importFrom(data.table,.SD)
importFrom(data.table,as.IDate)
importFrom(data.table,as.data.table)
importFrom(data.table,copy)
importFrom(data.table,data.table)
Expand All @@ -65,9 +68,12 @@ importFrom(data.table,melt)
importFrom(data.table,rbindlist)
importFrom(data.table,setDT)
importFrom(data.table,setcolorder)
importFrom(data.table,setnafill)
importFrom(data.table,setnames)
importFrom(data.table,setorderv)
importFrom(data.table,shift)
importFrom(lme4,findbars)
importFrom(lme4,nobars)
importFrom(posterior,default_convergence_measures)
importFrom(posterior,mad)
importFrom(posterior,quantile2)
Expand All @@ -76,6 +82,7 @@ importFrom(purrr,map)
importFrom(purrr,map_chr)
importFrom(purrr,map_dbl)
importFrom(purrr,reduce)
importFrom(purrr,transpose)
importFrom(rstan,expose_stan_functions)
importFrom(rstan,stanc)
importFrom(scales,comma)
Expand Down
29 changes: 29 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
# epinowcast 0.1.0

This is a major release and contains multiple breaking changes. If needing the old interface please install `0.0.7` from GitHub. A major focus of this release has been improving the user experience with an increase in modularity, development of a flexible and full featured formula interface, and hopefully future proofing as far as possible. For ease, we have stratified changes below into interface, package, documentation, and model changes.

## Interface

* A fully featured and flexible formula interface has been added that allows the specification of fixed effects, `lme4` random effects, and random walks. See [#27](https://github.com/epiforecasts/epinowcast/pull/27) by [@seabbs](https://github.com/seabbs).

## Package

* A new helper function `enw_delay_metadata()` has been added. This produces metadata about the delay distribution vector that may be helpful in future modelling. This prepares the way for [#4](https://github.com/epiforecasts/epinowcast/issues/4) where this data frame will be combined with the reference metadata in order to build non-parametric hazard reference and delay based models. In addition to adding this function, it has also been added to the output of `enw_preprocess_data()` in order to make the metadata readily available to end-users. See [#80](https://github.com/epiforecasts/epinowcast/pull/80) by [@seabbs](https://github.com/seabbs).
* Two new helper functions `enw_filter_reference_dates()` and `enw_filter_report_dates()` have been added. These replace `enw_retrospective_data()` but allow users to similarly construct retrospective data. Splitting these functions out into components also allows for additional use cases that were not previously possible. See [#82](https://github.com/epiforecasts/epinowcast/pull/82) by [@sbfnk](https://github.com/sbfnk) and [@seabbs](https://github.com/seabbs).
* The internal grouping variables have been refactored to reduce the chance of clashes with columns in the data frames supplied by the user. There will also be an error thrown in case of a variable clash, making preprocessing safer. See [#102](https://github.com/epiforecasts/epinowcast/pull/102) by [@adrian-lison](https://github.com/adrian-lison) and [@seabbs](https://github.com/seabbs), which solves [#99](https://github.com/epiforecasts/epinowcast/issues/99).

## Model

* Added support for parametric exponential delay distributions (note that this is comparable to an intercept-only non-parametric hazard model) and potentially no parametric delay (though this will currently throw an error due to the lack of appropriate non-parametric hazard). See [#84](https://github.com/epiforecasts/epinowcast/pull/84) by [@seabbs](https://github.com/seabbs).
* Update the expectation random walk model to use a more efficient `cumulative_sum` implementation suggested by [@adrian-lison](https://github.com/adrian-lison) in [#98](https://github.com/epiforecasts/epinowcast/issues/98)]. See [#103](https://github.com/epiforecasts/epinowcast/pull/103/) by [@seabbs](https://github.com/seabbs).

## Documentation

* The model descriptipn has been updated to reflect the currently implemented model and to improve readability. The use use of reference and report date nomenclature has also been standardised across the package. See [#71](https://github.com/epiforecasts/epinowcast/pull/71) by [@sbfnk](https://github.com/sbfnk) and [@seabbs](https://github.com/seabbs).

## Internals

* Array declarations in the stan model have been updated. To maintain compatibility with [expose_stan_fns()] (which itself depends on `rstan`), additional functionality has been added to parse stan code in this function. See [#74](https://github.com/epiforecasts/epinowcast/issues/74), [#85](https://github.com/epiforecasts/epinowcast/pull/85#issuecomment-1172010003), and [#93](https://github.com/epiforecasts/epinowcast/pull/93) by [@sbfnk](https://github.com/sbfnk) and [@seabbs](https://github.com/seabbs).
* Remove spurious warnings due to missing initial values for optional parameters. See [#76](https://github.com/epiforecasts/epinowcast/issues/75) by [@sbfnk](https://github.com/sbfnk) and [@seabbs](https://github.com/seabbs).


# epinowcast 0.0.7

* Adds additional quality of life data processing so that the maximum number (`max_confirm`) of notifications is available in every row (for both cumulative and incidence notifications) and the cumulative and daily empirical proportion reported are calculated for the user during pre-processing (see [#62](https://github.com/epiforecasts/epinowcast/pull/62) by [@seabbs](https://github.com/seabbs)).
Expand Down
56 changes: 56 additions & 0 deletions R/check.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,59 @@ check_quantiles <- function(posterior, req_probs = c(0.5, 0.95, 0.2, 0.8)) {
}
return(invisible(NULL))
}

#' Check Report and Reference Dates are present
#'
#' @param obs An observation data frame containing \code{report_date} and
#' \code{reference_date} columns.
#'
#' @return Returns the input data.frame with dates converted to date format
#' if not already.
#'
#' @importFrom data.table as.data.table copy
#' @family check
check_dates <- function(obs) {
obs <- data.table::as.data.table(obs)
obs <- data.table::copy(obs)
if (is.null(obs$reference_date) && is.null(obs$report_date)) {
stop(
"Both reference_date and report_date must be present in order to use this
function"
)
} else if (is.null(obs$reference_date)) {
stop("reference_date must be present")
} else if (is.null(obs$report_date)) {
stop("report_date must be present")
}
obs[, report_date := as.IDate(report_date)]
obs[, reference_date := as.IDate(reference_date)]
return(obs[])
}

#' Check Observations for reserved grouping variables
#'
#' @param obs An observation data frame that does not contain `.group`,
#' `.old_group`, or `.new_group` as these are reserved variables.
#'
#' @return NULL
#'
#' @family check
check_group <- function(obs) {
if (!is.null(obs$.group)) {
stop(
".group is a reserved variable and must not be present in the input
data"
)
} else if (!is.null(obs$.new_group)) {
stop(
".new_group is a reserved variable and must not be present in the input
data"
)
} else if (!is.null(obs$.old_group)) {
stop(
".old_group is a reserved variable and must not be present in the input
data"
)
}
return(invisible(NULL))
}
7 changes: 7 additions & 0 deletions R/epinowcast-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#' @keywords internal
#' @aliases epinowcast-package NULL
"_PACKAGE"

## usethis namespace: start
## usethis namespace: end
NULL
4 changes: 2 additions & 2 deletions R/epinowcast.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#' @export
epinowcast <- function(pobs,
reference_effects = epinowcast::enw_formula(
pobs$metareference[[1]]
~1, pobs$metareference[[1]]
),
report_effects = epinowcast::enw_formula(
pobs$metareport[[1]]
~1, pobs$metareport[[1]]
),
priors = epinowcast::enw_priors(),
distribution = "lognormal",
Expand Down
Loading