validate_lifetable: Validate life table

View source: R/validate_lifetable.R

validate_lifetableR Documentation

Validate life table

Description

Check life table, id columns, life table parameter columns, and other inputs to functions in this package.

Usage

validate_lifetable(
  dt,
  id_cols = c(),
  param_cols = c(),
  assert_uniform_age_length = FALSE,
  assert_uniform_terminal_age = FALSE,
  assert_age_start_0 = FALSE,
  assert_na = NA
)

Arguments

dt

[data.table()]
Input life tables

id_cols

[character()]
Columns that uniquely identify each row of dt.

param_cols

[character()]
Columns containing life table parameters (qx, lx, etc.)

assert_uniform_age_length

[logical()]
Whether to check that the age groups in the lifetable are all of the same length except for the terminal age group.

assert_uniform_terminal_age

[logical()]
Whether to check that each terminal age group starts at the same age.

assert_age_start_0

[logical()]
Whether to check that the youngest age group starts at age zero.

assert_na

[logical()]
Whether to check for NA values in the generated variable.

Details

This function performs the following checks:

id_cols is a character vector, 'age_start' and 'age_end' are included, and no other age variables are included.

dt is data.table, is unique by id_cols, has all id_cols and param_cols, 'age_start', 'age_end', and parameter columns are numeric, all life table parameters >= 0, parameters qx, lx, dx <= 1.

assert_na check assert_na is a logical.

Value

Invisibly returns input dt. Fails if any assertion fails.


ihmeuw-demographics/demCore documentation built on Feb. 24, 2024, 11:05 p.m.