Skip to contents

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.

Value

A tibble

Scaled SVDs of demographic databases in bage

See also

Examples

## SVD for females and males combined
generate(HMD)
#> # A tibble: 2,220 × 3
#>    draw   age   value
#>    <fct>  <fct> <dbl>
#>  1 Draw 1 0     -3.04
#>  2 Draw 1 1     -5.05
#>  3 Draw 1 2     -5.89
#>  4 Draw 1 3     -6.39
#>  5 Draw 1 4     -6.78
#>  6 Draw 1 5     -7.06
#>  7 Draw 1 6     -7.31
#>  8 Draw 1 7     -7.55
#>  9 Draw 1 8     -7.77
#> 10 Draw 1 9     -7.94
#> # ℹ 2,210 more rows

## separate SVDs for females and males
generate(HMD, indep = TRUE) 
#> # A tibble: 4,440 × 4
#>    draw   sexgender age   value
#>    <fct>  <fct>     <fct> <dbl>
#>  1 Draw 1 Female    0     -3.26
#>  2 Draw 1 Female    1     -5.55
#>  3 Draw 1 Female    2     -6.14
#>  4 Draw 1 Female    3     -6.43
#>  5 Draw 1 Female    4     -6.63
#>  6 Draw 1 Female    5     -6.81
#>  7 Draw 1 Female    6     -6.95
#>  8 Draw 1 Female    7     -7.06
#>  9 Draw 1 Female    8     -7.14
#> 10 Draw 1 Female    9     -7.26
#> # ℹ 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
#>    <fct>  <fct> <dbl>
#>  1 Draw 1 0     -3.27
#>  2 Draw 1 1-4   -6.06
#>  3 Draw 1 5-9   -7.66
#>  4 Draw 1 10-14 -8.14
#>  5 Draw 1 15-19 -7.51
#>  6 Draw 1 20-24 -7.09
#>  7 Draw 1 25-29 -7.05
#>  8 Draw 1 30-34 -6.96
#>  9 Draw 1 35-39 -6.77
#> 10 Draw 1 40-44 -6.51
#> # ℹ 270 more rows