Closed njtierney closed 1 year ago
new behaviour
library(conmat)
perth <- abs_age_lga("Perth (C)")
age_breaks_0_75 <- c(seq(0, 75, by = 5), Inf)
age_breaks_0_80 <- c(seq(0, 80, by = 5), Inf)
perth_contact_0_75 <- extrapolate_polymod(
perth,
age_breaks = age_breaks_0_75
)
perth_contact_0_75
#>
#> ── Setting Prediction Matrices ─────────────────────────────────────────────────
#> A list of matrices containing the model predicted contact rate between ages in
#> each setting.
#> There are 16 age breaks, ranging 0-75+ years, with a regular 5 year interval
#> • home: a 16x16 <matrix>
#> • work: a 16x16 <matrix>
#> • school: a 16x16 <matrix>
#> • other: a 16x16 <matrix>
#> • all: a 16x16 <matrix>
#> ℹ Access each <matrix> with `x$name`
#> ℹ e.g., `x$home`
perth_ngm_0_75 <- generate_ngm(perth_contact_0_75,
age_breaks = age_breaks_0_75,
R_target = 1.5)
# but this doesn't work unless you refit the extrapolated model
perth_ngm_0_80 <- generate_ngm(perth_contact_0_75,
age_breaks = age_breaks_0_80,
R_target = 1.5)
#> Error in `check_age_breaks()` at conmat/R/generate-ngm.R:130:2:
#> ! Age breaks must be the same, but they are different:
#> `x[14:17]`: 65 70 75 Inf
#> `age_breaks[14:18]`: 65 70 75 80 Inf
#> ℹ You can check the age breaks using `age_breaks(<object>)`
#> Backtrace:
#> ▆
#> 1. ├─conmat::generate_ngm(...)
#> 2. └─conmat:::generate_ngm.conmat_setting_prediction_matrix(...) at conmat/R/generate-ngm.R:101:2
#> 3. └─conmat:::check_age_breaks(x = age_breaks(x), y = age_breaks, x_arg = "x", y_arg = "age_breaks") at conmat/R/generate-ngm.R:130:2
#> 4. └─rlang::abort(...) at conmat/R/utils.R:424:4
Created on 2023-03-08 with reprex v2.0.2
under the hood this uses the internal function check_age_breaks()
, which uses waldo::compare()
conmat:::check_age_breaks(
x = c(1,2,3),
y = c(1,2,3)
)
conmat:::check_age_breaks(
x = c(1,2,3,Inf),
y = c(1,2,3)
)
#> Error in `conmat:::check_age_breaks()`:
#> ! Age breaks must be the same, but they are different:
#> `old`: 1 2 3 Inf
#> `new`: 1 2 3
#> ℹ You can check the age breaks using `age_breaks(<object>)`
#> Backtrace:
#> ▆
#> 1. └─conmat:::check_age_breaks(x = c(1, 2, 3, Inf), y = c(1, 2, 3))
#> 2. └─rlang::abort(...) at conmat/R/utils.R:424:4
Created on 2023-03-08 with reprex v2.0.2
Currently within
apply_vaccination
we just check that certain dimensions match - I think it is better to check that the age breaks are the same, but for this case, I think that these are the same, but I'm not sure what sort of method we would use to compare them -80+
is the same asc(80, Inf)
, and is0-5, 5-10
the same as0-4, 5-11
?Created on 2023-01-17 with reprex v2.0.2
Session info
``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.2.1 (2022-06-23) #> os macOS Monterey 12.3.1 #> system aarch64, darwin20 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Australia/Brisbane #> date 2023-01-17 #> pandoc 2.19.2 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.2.0) #> cli 3.4.1 2022-09-23 [1] CRAN (R 4.2.0) #> codetools 0.2-18 2020-11-04 [1] CRAN (R 4.2.1) #> colorspace 2.0-3 2022-02-21 [1] CRAN (R 4.2.0) #> conmat * 0.0.1.9000 2023-01-16 [1] local #> countrycode 1.4.0 2022-05-04 [1] CRAN (R 4.2.0) #> curl 4.3.3 2022-10-06 [1] CRAN (R 4.2.0) #> data.table 1.14.6 2022-11-16 [1] CRAN (R 4.2.0) #> DBI 1.1.3 2022-06-18 [1] CRAN (R 4.2.0) #> digest 0.6.30 2022-10-18 [1] CRAN (R 4.2.0) #> dotCall64 1.0-2 2022-10-03 [1] CRAN (R 4.2.0) #> dplyr 1.0.10 2022-09-01 [1] CRAN (R 4.2.0) #> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.2.0) #> evaluate 0.18 2022-11-07 [1] CRAN (R 4.2.0) #> fansi 1.0.3 2022-03-24 [1] CRAN (R 4.2.0) #> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.2.0) #> fields 14.1 2022-08-12 [1] CRAN (R 4.2.0) #> fs 1.5.2 2021-12-08 [1] CRAN (R 4.2.0) #> furrr 0.3.1 2022-08-15 [1] CRAN (R 4.2.0) #> future 1.29.0 2022-11-06 [1] CRAN (R 4.2.0) #> generics 0.1.3 2022-07-05 [1] CRAN (R 4.2.0) #> ggplot2 3.4.0 2022-11-04 [1] CRAN (R 4.2.0) #> globals 0.16.2 2022-11-21 [1] CRAN (R 4.2.1) #> glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.0) #> gridExtra 2.3 2017-09-09 [1] CRAN (R 4.2.0) #> gtable 0.3.1 2022-09-01 [1] CRAN (R 4.2.0) #> highr 0.9 2021-04-16 [1] CRAN (R 4.2.0) #> hms 1.1.2 2022-08-19 [1] CRAN (R 4.2.0) #> htmltools 0.5.3 2022-07-18 [1] CRAN (R 4.2.0) #> httr 1.4.4 2022-08-17 [1] CRAN (R 4.2.0) #> jsonlite 1.8.3 2022-10-21 [1] CRAN (R 4.2.0) #> knitr 1.41 2022-11-18 [1] CRAN (R 4.2.0) #> lattice 0.20-45 2021-09-22 [1] CRAN (R 4.2.1) #> lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.2.0) #> listenv 0.8.0 2019-12-05 [1] CRAN (R 4.2.0) #> lubridate 1.9.0 2022-11-06 [1] CRAN (R 4.2.0) #> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.0) #> maps 3.4.1 2022-10-30 [1] CRAN (R 4.2.0) #> Matrix 1.5-3 2022-11-11 [1] CRAN (R 4.2.0) #> mgcv 1.8-41 2022-10-21 [1] CRAN (R 4.2.0) #> munsell 0.5.0 2018-06-12 [1] CRAN (R 4.2.0) #> nlme 3.1-160 2022-10-10 [1] CRAN (R 4.2.0) #> oai 0.4.0 2022-11-10 [1] CRAN (R 4.2.0) #> parallelly 1.32.1 2022-07-21 [1] CRAN (R 4.2.0) #> pillar 1.8.1 2022-08-19 [1] CRAN (R 4.2.0) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.2.0) #> plyr 1.8.8 2022-11-11 [1] CRAN (R 4.2.0) #> purrr * 0.3.5 2022-10-06 [1] CRAN (R 4.2.0) #> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.2.0) #> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.2.0) #> R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.2.0) #> R.utils 2.12.2 2022-11-11 [1] CRAN (R 4.2.0) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.0) #> Rcpp 1.0.9 2022-07-08 [1] CRAN (R 4.2.0) #> readr 2.1.3 2022-10-01 [1] CRAN (R 4.2.0) #> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.2.0) #> rlang 1.0.6 2022-09-24 [1] CRAN (R 4.2.0) #> rmarkdown 2.18 2022-11-09 [1] CRAN (R 4.2.0) #> rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.2.0) #> scales 1.2.1 2022-08-20 [1] CRAN (R 4.2.0) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.0) #> socialmixr 0.2.0 2022-10-27 [1] CRAN (R 4.2.0) #> spam 2.9-1 2022-08-07 [1] CRAN (R 4.2.0) #> stringi 1.7.8 2022-07-11 [1] CRAN (R 4.2.0) #> stringr 1.5.0 2022-12-02 [1] CRAN (R 4.2.0) #> styler 1.8.1 2022-11-07 [1] CRAN (R 4.2.0) #> tibble 3.1.8 2022-07-22 [1] CRAN (R 4.2.0) #> tidyr 1.2.1 2022-09-08 [1] CRAN (R 4.2.0) #> tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.2.0) #> timechange 0.1.1 2022-11-04 [1] CRAN (R 4.2.0) #> tzdb 0.3.0 2022-03-28 [1] CRAN (R 4.2.0) #> utf8 1.2.2 2021-07-24 [1] CRAN (R 4.2.0) #> vctrs 0.5.1 2022-11-16 [1] CRAN (R 4.2.0) #> viridis 0.6.2 2021-10-13 [1] CRAN (R 4.2.0) #> viridisLite 0.4.1 2022-08-22 [1] CRAN (R 4.2.0) #> withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.0) #> wpp2017 1.2-3 2020-02-10 [1] CRAN (R 4.2.0) #> xfun 0.35 2022-11-16 [1] CRAN (R 4.2.0) #> xml2 1.3.3 2021-11-30 [1] CRAN (R 4.2.0) #> yaml 2.3.6 2022-10-18 [1] CRAN (R 4.2.0) #> #> [1] /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library #> #> ────────────────────────────────────────────────────────────────────────────── ```