Learn R Programming

qlifetable (version 0.0.1-13)

coord_age: Time elapsed (in years) since last birthday and the date of the event

Description

Computes the time(s) elapsed (in years) between the date(s) of last birthday and the date(s) of event(s) for each member of a population. The age coordinate(s) corresponding to an 1x1-year Lexis diagram, using by default the same length of year employed to compute the (related) time coordinate(s).

Usage

coord_age(
  date.birth,
  date.event,
  random.b = TRUE,
  random.e = TRUE,
  constant.age.year = FALSE
)

Value

A numeric vector of the same length as data.birth

Arguments

date.birth

A character vector with the dates of birth in format either "yyyy-mm-dd" or "yyyy-mm-dd hour:min:secs" (for instance, "2016-01-20 12:00:00") of a population. If "hour:min:secs" is omitted the function imputes either "12:00:00", if `random.b = FALSE`, or a random hour by default.

date.event

A character vector with the dates of events in format either "yyyy-mm-dd" or "yyyy-mm-dd hour:min:secs" (for instance, "2016-01-20 12:00:00") of a population. If "hour:min:secs" is omitted the function imputes either "12:00:00", if `random.e = FALSE`, or a random hour, by default. This vector must have either length 1, when the aim is to compute for all the members of the population the age coordinate in an 1x1-year Lexis diagram in the same temporal point, or the same length as `date.birth`, when the aim is to compute for each member of the population the age coordinate in the moment of the event (e.g., death).

random.b

A `TRUE/FALSE` argument indicating whether the exact moment ("hour:min:secs") when the birth occurs within the day is randomly selected. If TRUE, this overwrites "hour:min:secs" in `date.birth` even if those have been declared. By default, TRUE.

random.e

A `TRUE/FALSE` argument indicating whether the exact moment ("hour:min:secs") when the event occurs within the day is randomly selected. If TRUE, this overwrites "hour:min:secs" in `date.event` even if those have been declared. By default, TRUE.

constant.age.year

A `TRUE/FALSE` argument indicating whether the length of the year should be constant, 365.25 days, or variable, depending on the time lived for the person in each year since her/his dates of birth and event. By default, FALSE. The advantage of using a non-constant (person-dependent) length of year is congruence when estimating time exposed at risk: in each year the time exposed along the time and age axes will coincide.

Author

Jose M. Pavia pavia@uv.es

Josep Lledo josep.lledo@uv.es

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. tools:::Rd_expr_doi("10.1111/rssa.12769")

See Also

coord_time, exact_age

Examples

Run this code
dates.b <- c("1920-05-13", "1999-04-12", "2019-01-01")
dates.e <- c("2002-03-23", "2009-04-12", "2019-01-01")
coord_age(dates.b, dates.e)

Run the code above in your browser using DataLab