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     -4.76
#>  2 Draw 1 1     -6.70
#>  3 Draw 1 2     -7.08
#>  4 Draw 1 3     -7.30
#>  5 Draw 1 4     -7.42
#>  6 Draw 1 5     -7.48
#>  7 Draw 1 6     -7.53
#>  8 Draw 1 7     -7.57
#>  9 Draw 1 8     -7.57
#> 10 Draw 1 9     -7.57
#> # ℹ 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.25
#>  2 Draw 1 Female    1     -5.10
#>  3 Draw 1 Female    2     -5.82
#>  4 Draw 1 Female    3     -6.26
#>  5 Draw 1 Female    4     -6.58
#>  6 Draw 1 Female    5     -6.83
#>  7 Draw 1 Female    6     -7.05
#>  8 Draw 1 Female    7     -7.25
#>  9 Draw 1 Female    8     -7.43
#> 10 Draw 1 Female    9     -7.58
#> # ℹ 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     -4.17
#>  2 Draw 1 1-4   -6.50
#>  3 Draw 1 5-9   -7.62
#>  4 Draw 1 10-14 -7.77
#>  5 Draw 1 15-19 -6.90
#>  6 Draw 1 20-24 -6.48
#>  7 Draw 1 25-29 -6.48
#>  8 Draw 1 30-34 -6.47
#>  9 Draw 1 35-39 -6.37
#> 10 Draw 1 40-44 -6.16
#> # ℹ 270 more rows