Skip to content

Commit

Permalink
version 0.0.2-5
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose M. Pavía authored and cran-robot committed Jun 29, 2024
1 parent e04046d commit b3b0c44
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 52 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: qlifetable
Title: Managing and Building of Quarterly Life Tables
Version: 0.0.2-4
Version: 0.0.2-5
Authors@R:
c(person(given = "Jose M.",
family = "Pavía",
Expand All @@ -23,7 +23,7 @@ Description: Manages, builds and computes statistics and datasets for the
Pavía and Lledó (2022) <doi:10.1111/rssa.12769>.
Pavía and Lledó (2023) <doi:10.1017/asb.2023.16>.
Acknowledgements:
The authors wish to thank Consellería de Educación, Universidades y Empleo, Generalitat Valenciana (grant AICO/2021/257), Ministerio de Economía e Innovación (grant PID2021-128228NB-I00) and Fundación Mapfre (grant 'Modelización espacial e intra-anual de la mortalidad en España. Una herramienta automática para el cálculo de productos de vida') for supporting this research.
The authors wish to thank Consellería de Educación, Universidades y Empleo, Generalitat Valenciana (grant AICO/2021/257), Ministerio de Ciencia e Innovación (grant PID2021-128228NB-I00) and Fundación Mapfre (grant 'Modelización espacial e intra-anual de la mortalidad en España. Una herramienta automática para el cálculo de productos de vida') for supporting this research.
License: EPL
Encoding: UTF-8
Imports: stats, methods
Expand All @@ -32,8 +32,8 @@ LazyData: true
RoxygenNote: 7.2.3
Depends: R (>= 3.5.0)
NeedsCompilation: no
Packaged: 2024-01-24 09:52:30 UTC; mariaamparo
Packaged: 2024-06-25 13:28:38 UTC; mariaamparo
Author: Jose M. Pavía [aut, cre] (<https://orcid.org/0000-0002-0129-726X>),
Josep Lledó [aut] (<https://orcid.org/0000-0002-7475-8549>)
Repository: CRAN
Date/Publication: 2024-01-24 14:40:09 UTC
Date/Publication: 2024-06-28 07:30:07 UTC
26 changes: 13 additions & 13 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
5f2f5de43b7b5676a3b23d8f61dddefd *DESCRIPTION
fb94c6c932017ecc6d063c913f0b9e47 *DESCRIPTION
45b44298d41cc2081f8f4f3a0ef60b2b *LICENSE.note
cbed70e8c98c523dd6d2365bce95ab9c *NAMESPACE
790138ffb94994b7bf2afea31511be33 *NEWS.md
dc2d34634bda1d6efc5aacb72b6d36ac *R/SAI_shortcut_1.R
0fb168371356ded9b128bb31ac822ccd *R/annual2quarterly.R
f855e32614b43c1927511b7f9941df8e *NEWS.md
85260a9adb1a3d456efc11e634f3ab72 *R/SAI_shortcut_1.R
891e5879efa3a6dab1a476e05acb507e *R/annual2quarterly.R
5d5f6d99960a207cf7dc7d092d3b5de9 *R/auxiliar_functions.R
cfe7a685d4ba06e35c50ee8209a074a6 *R/compute_SAI.R
1036a01a179e5587a5fa3e8e7a6f3845 *R/compute_SAI.R
9c88d2c45b392e2e3c4155185ca5c2b7 *R/coord_age.R
e36db8c885172c33b7800881960c517c *R/coord_time.R
ce8ecf14aa7c7bcfa0a79e2092077508 *R/count_events_quarter.R
6b56c7468fcf429e72af5bb06d7221af *R/crude_mx.R
ceb321d0ce179fbefc595c42f08ffcac *R/crude_mx_sh2.R
7016ee33ba7f51c9589f9805baabc4ea *R/crude_mx_sh3.R
3063689b6110662cbc8292c96c1522d3 *R/crude_mx_sh2.R
ab197341184910a0b889e863e2ddba5c *R/crude_mx_sh3.R
425270b41d94a98b421096f7586d8e37 *R/distribute_excess.R
1a7c6f72bb9138590cd5fba84ead92d9 *R/exact_age.R
f5f8cb2fc99fb1651f46591482784c6a *R/plot.R
2d6de2b5a694e4478d1d5ede745a9d7e *R/plot.SAI.R
0a2e8d6c93aea78bd0bf06634c357e61 *R/plot.SAI.R
561d3d867600fa7fd94929b19f29511a *R/quarterly_variables.R
6a91f1dacc16f41296feb79560493249 *R/time_exposed_ins.R
2d2f89bacbc11edf14264aa2039331e8 *R/time_exposed_newborns.R
Expand All @@ -27,16 +27,16 @@ e9d08b8550667da6f5b586ed4eea0a9d *data/death_2006.rda
74ebb2ba88eba08b5a1ee0fefeaf0ba2 *data/emi_2006.rda
ddd59fded156340ca89982b92a0d2986 *data/immi_2006.rda
9ba6266555bd1dd3664fca0fea859140 *data/pop_2006.rda
cf7adcb15ce50586b1ead0b97621971a *man/SAI_shortcut_1.Rd
61e86a238f600350ac75bbb78e48587e *man/annual2quarterly.Rd
51828722cafb9cee29a358622e6d6156 *man/SAI_shortcut_1.Rd
611656db869341e58d416c60988eb245 *man/annual2quarterly.Rd
5f95f1293c6db8d7bf7602d062be1f82 *man/birth_2006.Rd
42ff0eeca0112d054b6709ee78e66dbe *man/compute_SAI.Rd
737147966761929882e47610586c42aa *man/compute_SAI.Rd
75ca7192b81aadf56a1dc007d7ac459b *man/coord_age.Rd
c55920c54bb42693eb68bc5353fcc74a *man/coord_time.Rd
d23ca1080ea40f9c61672cba5c3d4061 *man/count_events_quarter.Rd
8abab62e05d5da8e8b7604f112e3f8f7 *man/crude_mx.Rd
41262e11f349a4fce99ff9a49a0dca50 *man/crude_mx_sh2.Rd
a837d6b19f4307942665cac5a0f4a465 *man/crude_mx_sh3.Rd
8e2af9d66750f70bd3227d9a5aa89e57 *man/crude_mx_sh2.Rd
187fa041476b56eff4118d212e2934c7 *man/crude_mx_sh3.Rd
40246ccff585f1133f61a8514b3bd041 *man/death_2006.Rd
115621d50536b1790e189392ed172726 *man/distribute_excess.Rd
bc6d4338a796bd9bc1beab23bd7fc895 *man/emi_2006.Rd
Expand Down
8 changes: 7 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
### Package changes from previous qlifetable version 0.0.2-4

The way grobs are defined in the method **plot** for objects of class SAI has been modified to accomodate some changes made in new versions of ggplot2 (>=3.5.0).

A bug in the function **annual2quaterly** has been fixed when its input annual life table is defined using death rates (mx).

### Package changes from previous qlifetable version 0.0.1-15

The previous version (0.0.1-15= of qlifetable just computes from microdata the summary statistics to build quarterly life tables. This new version includes two new sets of functions. On the one hand, `qlifetable` now incorporates a bunch of functions to construct from summary statistics Seasonal-ageing indexes (SAIs) and quarterly life tables and, on the other hand, the new version also has new functions to estimate SAIs approximations as detailed in Pavía and Lledó (2023) <doi:10.1017/asb.2023.16>.
The previous version (0.0.1-15) of qlifetable just computes from microdata the summary statistics to build quarterly life tables. This new version includes two new sets of functions. On the one hand, `qlifetable` now incorporates a bunch of functions to construct from summary statistics Seasonal-ageing indexes (SAIs) and quarterly life tables and, on the other hand, the new version also has new functions to estimate SAIs approximations as detailed in Pavía and Lledó (2023) <doi:10.1017/asb.2023.16>.

The list of new functions includes:

Expand Down
2 changes: 2 additions & 0 deletions R/SAI_shortcut_1.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
#' e.death <- count_events_quarter(temp)
#' SAI.example <- SAI_shortcut_1(e.death, e.death)
#' }
#'
#' # Fast example
#' dates.b <- c("2017-05-13", "2018-04-12", "2018-01-01")
#' dates.d <- c("2020-09-23", "2021-10-11", "2021-11-23")
#' x <- quarterly_variables(dates.b, dates.d)
Expand Down
22 changes: 9 additions & 13 deletions R/annual2quarterly.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @references Pavia, JM and Lledo, J (2022). Estimation of the Combined Effects of Ageing and Seasonality on Mortality Risk. An application to Spain. *Journal of the Royal Statistical Society, Series A (Statistics in Society)*, 185(2), 471-497. \doi{10.1111/rssa.12769}
#'
#' @param table.a A data.frame corresponding to the reference annual life table. The life table can be defined via
#' death rates (`mx`, default) or via death probabilities (`qx`). The first column of `table.a` refers to `age`,
#' via death probabilities (`qx`, default) or death rates (`mx`). The first column of `table.a` refers to `age`,
#' and the second column to either `mx` rates or `qx` probabilities. In case of using death probabilities (`qx`),
#' `table.a` can have an optional third column, which refers to the the average number of years lived
#' for those dying with age x, `ax`. If this last column is missing ax is assumed to be constant and equal to 0.5.
Expand Down Expand Up @@ -47,24 +47,20 @@
#' e.death <- e.death[e.death$age <= 100, ]
#' t.birth <- time_exposed_newborns(birth_2006$date.birth)
#' out <- crude_mx(t.stock, e.death, time.birth = t.birth)
#' SAI.example <- compute_SAI(out, out)}
#' SAI.example <- compute_SAI(out, out)
#' dx <- tapply(e.death$number.events, e.death$age, sum)
#' Lax <- tapply(t.stock$time.exposed, t.stock$age, sum)
#' table.ex <- data.frame(age = 0:100, mx.a = dx/Lax)
#' example <- annual2quarterly(table.a = table.ex, SAIs = SAI.example, mx = TRUE)
#' }
#'
#' dates.b <- c("2017-05-13", "2018-04-12", "2018-12-01")
#' t.stock <- time_exposed_stock(dates.b, year = 2020, type = "backward")
#' dates.bd <- c("2018-04-12")
#' dates.d <- c("2020-05-23")
#' x <- quarterly_variables(dates.bd, dates.d)
#' e.death <- count_events_quarter(x)
#' t.death <- time_exposed_outs(x)
#' out <- crude_mx(t.stock, e.death, t.death)
#' SAI.example <- compute_SAI(out, out)

annual2quarterly <- function(table.a, SAIs, mx = FALSE, min.age = 0, max.age = 100){

argg <- as.list(environment())
SAIs <- check_a2q(argg)

if (!mx){
if (mx){
colnames(table.a)[1L:2L] <- c("age", "mx")
} else {
table.a <- q2m(table.a)
Expand Down Expand Up @@ -115,7 +111,7 @@ q2m <- function(tabla){
colnames(tabla) <- c("age", "qx", "ax")
ax <- tabla[, 3L]
}
qx <- tabla[, 1L]
qx <- tabla[, 2L]
tabla$mx <- qx/(1 - (1- ax)*qx)
return(tabla)
}
Expand Down
2 changes: 2 additions & 0 deletions R/compute_SAI.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
#' out <- crude_mx(t.stock, e.death, time.birth = t.birth)
#' SAI.example <- compute_SAI(out, out)
#' }
#'
#' # Fast example
#' dates.b <- c("2017-05-13", "2018-04-12", "2018-12-01")
#' t.stock <- time_exposed_stock(dates.b, year = 2020, type = "backward")
#' dates.bd <- c("2018-04-12")
Expand Down
2 changes: 2 additions & 0 deletions R/crude_mx_sh2.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
#' e.death <- count_events_quarter(temp)
#' out <- crude_mx_sh2(pop, pop, e.death)
#' }
#'
#' # Fast example
#' pop.1 <- data.frame(age = c(40, 41), people = c(4134, 4353))
#' pop.2 <- data.frame(age = c(40, 41), people = c(4250, 4213))
#' dates.b <- c("1980-04-12")
Expand Down
2 changes: 2 additions & 0 deletions R/crude_mx_sh3.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
#' e.immi <- count_events_quarter(temp)
#' out <- crude_mx_sh3(pop, pop, e.death, e.emi, e.immi)
#' }
#'
#' # Fast example
#' pop.1 <- data.frame(age = c(rep(40, 4), rep(41, 4)), quarter = rep(1:4, 2), people = c(4134, 4353))
#' pop.2 <- data.frame(age = c(rep(40, 4), rep(41, 4)), quarter = rep(1:4, 2), people = c(4250, 4213))
#' dates.b <- c("1980-04-12")
Expand Down
24 changes: 14 additions & 10 deletions R/plot.SAI.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ plot_SAI_margins <- function(x, min.age = 1, max.age = 100, decimal.digits = 1,
ggplot2::aes(x = age.j, y = SAI.norm.j)) +
ggplot2::geom_line(col = color.main) +
ggplot2::geom_smooth(formula = y ~ x, se = F, method = "lm",
color = color.lm, size = 0.25) +
color = color.lm, linewidth = 0.25) +
ggplot2::geom_hline(yintercept = 1, col = color.hline, lty = 2) +
ggplot2::scale_x_continuous(breaks = axis.age.ticks) +
ggplot2::facet_wrap("Quarter") +
Expand Down Expand Up @@ -291,26 +291,30 @@ plot_SAI_margins <- function(x, min.age = 1, max.age = 100, decimal.digits = 1,
} else {
posiciones <- unique(seasonal.figure1$grobs[[2L]]$children[[1L]]$children[[5L]]$x)
}
posiciones <- c(0.145, 0.4575, 0.76)
ticks0 <- grid::segmentsGrob(x0 = posiciones, x1 = posiciones,
y0 = rep(1 - 0.007, length(posiciones)),
y1 = rep(1 - .018, length(posiciones)),
gp = grid::gpar(lwd = 1.35))
ticks0 <- grid::grobTree(blank, children = grid::gList(ticks0))

labels.ages0 <- grid::textGrob(axis.age.ticks, x = posiciones, y = rep(0.35, length(posiciones)),
gp = grid::gpar(cex = 8.7/12, col = "grey30"))
labels.ages0 <- grid::textGrob(axis.age.ticks, x = posiciones,
y = rep(0.35, length(posiciones)),
gp = grid::gpar(cex = 8.7/12, col = "grey30"))
labels.ages0 <- grid::grobTree(blank, children = grid::gList(labels.ages0))

ticks <- gridExtra::arrangeGrob( blank, ticks0, blank, blank,
ncol = 4L,
widths = ageing.figure1$widths[c(1L, 5L, 6L, 9L)])
#1 ticks <- gridExtra::arrangeGrob( blank, ticks0, blank, blank,
#1 ncol = 4L,
#1 widths = ageing.figure1$widths[c(1L, 5L, 6L, 9L)])
ticks <- gridExtra::arrangeGrob(ticks0)

labels.ages <- gridExtra::arrangeGrob( blank, labels.ages0, blank, blank,
ncol = 4L,
widths = ageing.figure1$widths[c(1L, 5L, 6L, 9L)])
#1 labels.ages <- gridExtra::arrangeGrob( blank, labels.ages0, blank, blank,
#1 ncol = 4L,
#1 widths = ageing.figure1$widths[c(1L, 5L, 6L, 9L)])

labels.ages <- gridExtra::arrangeGrob(labels.ages0)
ageing.figure <- grid::grobTree(ticks, children = grid::gList(ageing.figure1))
# ageing.figure <- grid::grobTree(labels.ages, children = grid::gList(ageing.figure))
ageing.figure <- grid::grobTree(labels.ages, children = grid::gList(ageing.figure))

ageing.label <- grid::textGrob(title.ageing, x = .48, y = 1.02, gp = grid::gpar(cex = .85))
ageing.label <- grid::grobTree(blank, children = grid::gList(ageing.label))
Expand Down
2 changes: 2 additions & 0 deletions man/SAI_shortcut_1.Rd

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

18 changes: 7 additions & 11 deletions man/annual2quarterly.Rd

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

2 changes: 2 additions & 0 deletions man/compute_SAI.Rd

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

2 changes: 2 additions & 0 deletions man/crude_mx_sh2.Rd

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

2 changes: 2 additions & 0 deletions man/crude_mx_sh3.Rd

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

0 comments on commit b3b0c44

Please sign in to comment.