expstudy()
creates a subclass, tbl_es
, of a dtplyr::lazy_dt()
, that
stores attributes relating to an experience study.These attributes provide
other package functions arguments which reduce time needed to review an
assumption.
Arguments
- data
the dataset of an experience study. Can be any kind of organized data (e.g.,
base::data.frame()
,tibble::tibble()
, etc.) but must be able to be converted to adata.table::data.table()
.- actuals
the observed variable (or variables) within the experience study (e.g., actual lapse counts for a lapse study).
- expecteds
the expected variable (or variables) within the experience study (e.g., actual deaths for a mortality study).
- exposures
the exposure variable (or variables) within the experience study. This will be the time the records spans in years (or within (0, 1) for records covering less than a year).
- variances
the variance variable (or variables) within the experience study. This may not be available for all studies, thus can be omitted. Variance is used for credibility calculations.
- keys
variables that uniquely describe every record within the experience study. This typically is policy number and a measure of time, such as annual or monthly duration. Can be omitted, but providing enables quicker binary searches within the
dtplyr::lazy_dt()
. For more information, refer to the data.table vignette:vignette('datatable-keys-fast-subset', package = 'data.table')
.
Examples
expstudy(
data = mortexp,
actuals = ACTUAL_DEATHS,
expecteds = EXPECTED_DEATHS,
exposures = EXPOSURE,
variances = VARIANCE_DEATHS
)
#> Source: local data table [175,491 x 18]
#> Call: `_DT26`
#>
#> AS_OF_DATE POLICY_HOLDER GENDER SMOKING_STATUS UNDERWRITING_CLASS INSURED_DOB
#> <date> <fct> <fct> <fct> <fct> <date>
#> 1 1998-04-30 PH_0001 MALE NON-SMOKER STANDARD 1948-09-10
#> 2 1998-05-31 PH_0001 MALE NON-SMOKER STANDARD 1948-09-10
#> 3 1998-06-30 PH_0001 MALE NON-SMOKER STANDARD 1948-09-10
#> 4 1998-07-31 PH_0001 MALE NON-SMOKER STANDARD 1948-09-10
#> 5 1998-08-31 PH_0001 MALE NON-SMOKER STANDARD 1948-09-10
#> 6 1998-09-30 PH_0001 MALE NON-SMOKER STANDARD 1948-09-10
#> # ℹ 175,485 more rows
#> # ℹ 12 more variables: ISSUE_DATE <date>, ISSUE_AGE <dbl>, ATTAINED_AGE <dbl>,
#> # DURATION_MONTH <int>, DURATION_YEAR <dbl>, POLICY_STATUS <fct>,
#> # TERMINATION_DATE <date>, EXPOSURE <dbl>, ACTUAL_DEATHS <dbl>,
#> # EXPECTED_MORTALITY_RT <dbl>, EXPECTED_DEATHS <dbl>, VARIANCE_DEATHS <dbl>
#>
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results