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

Complete CRAN checks for submission #170

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
^docs$
^pkgdown$
^touchstone$
^cran-comments\.md$
^paper$
11 changes: 9 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Package: conmat
Title: Builds contact matrices using GAMs and population data
Title: Builds Contact Matrices using GAMs and Population Data
Version: 0.0.2.9000
Authors@R: c(
person(given = "Nicholas",
family = "Tierney",
role = c("aut", "cre"),
role = c("aut", "cre", "cph"),
email = "[email protected]",
comment = c(ORCID = "https://orcid.org/0000-0003-1460-8722")),
person(given = "Nick",
Expand All @@ -17,6 +17,11 @@ Authors@R: c(
role = c("aut"),
email = "[email protected]",
comment = c(ORCID = "https://orcid.org/0000-0002-6982-5989")),
person(given = "Chitra",
family = "Saraswati",
role = c("aut"),
email = "[email protected]",
comment = c(ORCID = "https://orcid.org/0000-0002-8159-0414")),
person(given = "Michael",
family = "Lydeamore",
role = "aut",
Expand Down Expand Up @@ -71,3 +76,5 @@ Imports:
english,
waldo,
stringr
URL: https://github.com/idem-lab/conmat
BugReports: https://github.com/idem-lab/conmat/issues
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ S3method(get_age_population_function,data.frame)
S3method(population_label,conmat_population)
S3method(population_label,default)
S3method(predictions_to_matrix,predicted_contacts)
S3method(prepare_population_for_modelling,conmat_population)
S3method(prepare_population_for_modelling,data.frame)
S3method(print,conmat_age_matrix)
S3method(print,conmat_population)
S3method(print,conmat_setting_prediction_matrix)
Expand Down
16 changes: 8 additions & 8 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* `transmission_probability_matrix()` for creating new transmission probability
matrices

* there is now a print method for age group information in setting matrices - [#139](https://github.com/njtierney/conmat/issues/139)
* there is now a print method for age group information in setting matrices - [#139](https://github.com/idem-lab/conmat/issues/139)

* improved age break checking [#138](https://github.com/njtierney/conmat/issues/138)
* improved age break checking [#138](https://github.com/idem-lab/conmat/issues/138)

* extended `add_school_work_participation()`, `add_modelling_features()`, `fit_single_contact_model()`, `fit_setting_contacts()`, `estimate_setting_contacts()` to use different school and work demographics arguments. (#82 and #15, resolved by #153).

Expand Down Expand Up @@ -53,14 +53,14 @@

* Added a `NEWS.md` file to track changes to the package.
* Decouple prediction and estimation of models with `fit_setting_contacts` to
fit models, and `predict_setting_contacts` to predict. Fixes [#7](https://github.com/njtierney/conmat/issues/7)
* Implement parallelisation with `furrr`. Resolves [#31](https://github.com/njtierney/conmat/issues/31)
fit models, and `predict_setting_contacts` to predict. Fixes [#7](https://github.com/idem-lab/conmat/issues/7)
* Implement parallelisation with `furrr`. Resolves [#31](https://github.com/idem-lab/conmat/issues/31)
* Change argument of `fit_setting_contacts` from `survey_population` to just `population`
* Reduce vignette size, closes [#28](https://github.com/njtierney/conmat/issues/28)
* Add transmission probability data from Eyre et al., closes [#39](https://github.com/njtierney/conmat/issues/39)
* Add household adjustment - [#41](https://github.com/njtierney/conmat/issues/41)
* Reduce vignette size, closes [#28](https://github.com/idem-lab/conmat/issues/28)
* Add transmission probability data from Eyre et al., closes [#39](https://github.com/idem-lab/conmat/issues/39)
* Add household adjustment - [#41](https://github.com/idem-lab/conmat/issues/41)
* Added setting weights, related to #44 (but no longer Eyre weights)
* Added `apply_vaccination` to take in vaccination rates of ages and apply to contact matrices [#40](https://github.com/njtierney/conmat/issues/40)
* Added `apply_vaccination` to take in vaccination rates of ages and apply to contact matrices [#40](https://github.com/idem-lab/conmat/issues/40)
* Data from `get_polymod_population` has been revised as a result of the [socialmixr package](https://github.com/epiforecasts/socialmixr/blob/main/NEWS.md) being updated to version 0.2.0, where the world population data has been updated to 2017 by switching from the wpp2015 to wpp2017 package. We have explored the new data and found it to be very similar and should not introduce any errant errors. See the exploration [here](https://gist.github.com/njtierney/4862fa73abab97093d779fa7f2904d11).
* Added new print methods for: `conmat_setting_prediction_matrix`, `conmat_prediction_matrix`, `ngm_setting_matrix`, `setting_contact_model`, `setting_vaccination_matrix`, and `setting_data`, see #116. Main change is that list objects don't return the entire list and output but a summary of the list contents and details on what that object contains.
* Added a new S3 method for `conmat_population` to avoid fragile use of the `lower.age.limit` variable name. This resolves #77.
3 changes: 2 additions & 1 deletion R/add_population_age_to.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
#' `conmat_population` object, which specifies the `age` and `population`
#' columns. But it can optionally be any data frame with columns,
#' `lower.age.limit`, and `population`.
#' @return data frame
#' @return data frame of `contact_data` with the number of intergenerational
#' mixing contacts added.
#' @examples
#' age_min <- 10
#' age_max <- 15
Expand Down
4 changes: 2 additions & 2 deletions R/data_abs_employ_age_lga.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#' \item{total}{sum of these totals...or thereabouts??}
#' }
#' @note still need to finalise these columns
#' @source ABS.stat \url{https://stat.data.abs.gov.au/Index.aspx?} LABOUR >
#' Employment and Unemployment > Labour force status >
#' @source ABS.stat \url{https://www.abs.gov.au/statistics} LABOUR >
#' Employment and Unemployment > Labour force, Australia >
#' Census 2016, G43 labour status by age and sex (LGA)
"abs_employ_age_lga"
2 changes: 1 addition & 1 deletion R/data_abs_household_lga.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
#' \item{n_households}{number of households with that number of people}
#' }
#' @note still need to clean this
#' @source \url{https://stat.data.abs.gov.au/Index.aspx?Datasetcode=ABS_FAMILY_PROJ}
#' @source \url{https://www.abs.gov.au/statistics}
#' (downloaded the CSV) PEOPLE > People and Communities > Household Composition > Census 2016, T23 Household Composition By Number Of Persons Usually Resident (LGA)
"abs_household_lga"
1 change: 1 addition & 0 deletions R/generate-ngm.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#' for more detail.
#' @param ... extra arguments, currently not used
#' @name generate_ngm
#' @return A next generation matrix, containing the rates of contact between two age groups.
#' @examples
#' \dontrun{
#' perth <- abs_age_lga("Perth (C)")
Expand Down
5 changes: 5 additions & 0 deletions R/get-age-population-function-internals.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
#' @author njtierney
#' @keywords internal
#' @name prepare_population_for_modelling
#' @examples
#' prepare_population_for_modelling(get_polymod_population())
#'
#' @export
prepare_population_for_modelling <- function(data, ...) {
UseMethod("prepare_population_for_modelling")
}

#' @rdname prepare_population_for_modelling
#' @export
prepare_population_for_modelling.conmat_population <- function(data, ...) {
age_col <- age(data)
pop_col <- population(data)
Expand Down Expand Up @@ -58,6 +62,7 @@ prepare_population_for_modelling.conmat_population <- function(data, ...) {
#' @param age_col column of ages
#' @param pop_col column of population,
#' @param ... extra arguments
#' @export
prepare_population_for_modelling.data.frame <- function(data = data,
age_col = age_col,
pop_col = pop_col,
Expand Down
2 changes: 2 additions & 0 deletions R/get_polymod_per_capita_household_size.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#'
#' @return number, 3.248971
#' @author Nicholas Tierney
#' @examples
#' get_polymod_per_capita_household_size()
#' @export
get_polymod_per_capita_household_size <- function() {
mean(socialmixr::polymod$participants$hh_size)
Expand Down
21 changes: 0 additions & 21 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -226,25 +226,6 @@ ungroup_age_breaks <- function(x) {
unique() %>%
sort()
}
#
# group_age_breaks(1:10, pad_inf = FALSE)
# group_age_breaks(1:10, pad_inf = FALSE) %>% ungroup_age_breaks()
# group_age_breaks(1:10, pad_inf = TRUE)
# group_age_breaks(1:10, pad_inf = TRUE) %>% ungroup_age_breaks()
#
# group_age_breaks(c(1:10, Inf), pad_inf = TRUE)
# group_age_breaks(c(1:10, Inf), pad_inf = TRUE) %>% ungroup_age_breaks()
#
# group_age_breaks(c(1:10, Inf), pad_inf = FALSE)
# group_age_breaks(c(1:10, Inf), pad_inf = FALSE) %>% ungroup_age_breaks()
#
# group_age_breaks(age_breaks_0_80_plus)
# group_age_breaks(1:10, pad_inf = FALSE)
# group_age_breaks(1:9, pad_inf = FALSE)
# group_age_breaks(1:8, pad_inf = FALSE)
# group_age_breaks(1:10)
# group_age_breaks(1:9)
# group_age_breaks(1:8)

all_matrix <- function(x) {
all(vapply(
Expand Down Expand Up @@ -300,8 +281,6 @@ set_age_breaks_matrices <- function(list_matrix, age_breaks) {
)
}

# age_breaks(perth_contact_0_75)

remove_inf <- function(x) {
x_inf <- is.infinite(x)
if (!any(x_inf)) {
Expand Down
8 changes: 7 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ knitr::opts_chunk$set(

<!-- badges: start -->
[![R-CMD-check](https://github.com/idem-lab/conmat/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/idem-lab/conmat/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/idem-lab/conmat/branch/master/graph/badge.svg)](https://codecov.io/gh/idem-lab/conmat?branch=master)
[![Codecov test coverage](https://codecov.io/gh/idem-lab/conmat/branch/master/graph/badge.svg)](https://app.codecov.io/gh/idem-lab/conmat?branch=master)
<!-- badges: end -->

The goal of conmat is to make it easy to generate synthetic contact matrices for a given age population.
Expand Down Expand Up @@ -71,6 +71,12 @@ We need methods that allow for flexibly creating synthetic contact matrices for

## Installation

You can install the stable version from CRAN with:

```r
install.packages("conmat")
```

You can install the development version with:

```r
Expand Down
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

[![R-CMD-check](https://github.com/idem-lab/conmat/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/idem-lab/conmat/actions/workflows/R-CMD-check.yaml)
[![Codecov test
coverage](https://codecov.io/gh/idem-lab/conmat/branch/master/graph/badge.svg)](https://codecov.io/gh/idem-lab/conmat?branch=master)
coverage](https://codecov.io/gh/idem-lab/conmat/branch/master/graph/badge.svg)](https://app.codecov.io/gh/idem-lab/conmat?branch=master)
<!-- badges: end -->

The goal of conmat is to make it easy to generate synthetic contact
Expand Down Expand Up @@ -59,6 +59,12 @@ representation of community infection in many regions.

## Installation

You can install the stable version from CRAN with:

``` r
install.packages("conmat")
```

You can install the development version with:

``` r
Expand Down Expand Up @@ -127,6 +133,8 @@ contact_model <- fit_single_contact_model(
contact_data = polymod_contact_data,
population = polymod_survey_data
)
#> Warning in bgam.fit(G, mf, chunk.size, gp, scale, gamma, method = method, :
#> fitted rates numerically 0 occurred
```

This fits a generalised additive model (GAM), predicting the contact
Expand All @@ -145,9 +153,9 @@ contact_model
#> school_probability + work_probability + offset(log_contactable_population)
#>
#> Estimated degrees of freedom:
#> 1.85 3.95 3.82 7.10 7.59 4.77 total = 32.09
#> 1.01 4.33 4.24 7.03 7.58 4.75 total = 31.94
#>
#> fREML score: 24429.55 rank: 55/57
#> fREML score: 24021.47 rank: 55/57
```

We can use this contact model to then predict the contact rate in a new
Expand Down Expand Up @@ -201,16 +209,16 @@ synthetic_contact_fairfield
#> # A tibble: 324 × 3
#> age_group_from age_group_to contacts
#> <fct> <fct> <dbl>
#> 1 [0,5) [0,5) 0.00281
#> 2 [0,5) [5,10) 0.00318
#> 3 [0,5) [10,15) 0.00345
#> 4 [0,5) [15,20) 0.00571
#> 5 [0,5) [20,25) 0.0133
#> 6 [0,5) [25,30) 0.0261
#> 7 [0,5) [30,35) 0.0356
#> 8 [0,5) [35,40) 0.0372
#> 9 [0,5) [40,45) 0.0349
#> 10 [0,5) [45,50) 0.0317
#> 1 [0,5) [0,5) 0.00286
#> 2 [0,5) [5,10) 0.00309
#> 3 [0,5) [10,15) 0.00330
#> 4 [0,5) [15,20) 0.00562
#> 5 [0,5) [20,25) 0.0135
#> 6 [0,5) [25,30) 0.0266
#> 7 [0,5) [30,35) 0.0358
#> 8 [0,5) [35,40) 0.0370
#> 9 [0,5) [40,45) 0.0348
#> 10 [0,5) [45,50) 0.0318
#> # ℹ 314 more rows
```

Expand Down
5 changes: 5 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.
4 changes: 2 additions & 2 deletions man/abs_employ_age_lga.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/abs_household_lga.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/add_population_age_to.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions man/conmat-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified man/figures/README-plot-matrix-differents-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions man/generate_ngm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/get_polymod_per_capita_household_size.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions man/prepare_population_for_modelling.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading