Generate random age or age-sex profiles from
an object of class "bage_ssvd"
. An object
of class "bage_ssvd"
holds results from
an SVD decomposition of demographic
data.
Usage
# S3 method for class 'bage_ssvd'
generate(x, n_draw = 20, n_comp = NULL, indep = NULL, age_labels = NULL, ...)
Arguments
- x
An object of class
"bage_ssvd"
.- n_draw
Number of random draws to generate.
- n_comp
The number of components. The default is half the total number of components of
object
.- indep
Whether to use independent or joint SVDs for each sex/gender. If no value is supplied, an SVD with no sex/gender dimension is used. Note that the default is different from
SVD()
.- age_labels
Age labels for the desired age or age-sex profile. If no labels are supplied, the most detailed profile available is used.
- ...
Unused. Included for generic consistency only.
Scaled SVDs of demographic databases in bage
HMD
Mortality rates from the Human Mortality Database.
See also
components() Components used by SVD prior.
SVD()
SVD prior for term involving age.SVD_AR1()
,SVD_AR()
,SVD_RW()
,SVD_RW2()
Dynamic SVD priors for terms involving age and time.poputils::age_labels()
Generate age labels.
Examples
## SVD for females and males combined
generate(HMD)
#> # A tibble: 2,220 × 3
#> draw age value
#> <int> <chr> <dbl>
#> 1 1 0 -2.39
#> 2 1 1 -4.26
#> 3 1 2 -4.87
#> 4 1 3 -5.20
#> 5 1 4 -5.46
#> 6 1 5 -5.66
#> 7 1 6 -5.82
#> 8 1 7 -5.97
#> 9 1 8 -6.12
#> 10 1 9 -6.24
#> # ℹ 2,210 more rows
## separate SVDs for females and males
generate(HMD, indep = TRUE)
#> # A tibble: 4,440 × 4
#> draw sexgender age value
#> <int> <chr> <chr> <dbl>
#> 1 1 Female 0 -4.15
#> 2 1 Female 1 -6.35
#> 3 1 Female 2 -6.95
#> 4 1 Female 3 -7.26
#> 5 1 Female 4 -7.48
#> 6 1 Female 5 -7.65
#> 7 1 Female 6 -7.78
#> 8 1 Female 7 -7.89
#> 9 1 Female 8 -7.99
#> 10 1 Female 9 -8.07
#> # ℹ 4,430 more rows
## specify age groups
labels <- poputils::age_labels(type = "lt", max = 60)
generate(HMD, age_labels = labels)
#> # A tibble: 280 × 3
#> draw age value
#> <int> <chr> <dbl>
#> 1 1 0 -3.40
#> 2 1 1-4 -5.98
#> 3 1 5-9 -7.19
#> 4 1 10-14 -7.48
#> 5 1 15-19 -6.82
#> 6 1 20-24 -6.46
#> 7 1 25-29 -6.40
#> 8 1 30-34 -6.29
#> 9 1 35-39 -6.08
#> 10 1 40-44 -5.80
#> # ℹ 270 more rows