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     -5.02
#>  2 Draw 1 1     -7.47
#>  3 Draw 1 2     -7.86
#>  4 Draw 1 3     -8.04
#>  5 Draw 1 4     -8.14
#>  6 Draw 1 5     -8.19
#>  7 Draw 1 6     -8.22
#>  8 Draw 1 7     -8.22
#>  9 Draw 1 8     -8.22
#> 10 Draw 1 9     -8.21
#> # ℹ 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.85
#>  2 Draw 1 Female    1     -5.96
#>  3 Draw 1 Female    2     -6.48
#>  4 Draw 1 Female    3     -6.73
#>  5 Draw 1 Female    4     -6.90
#>  6 Draw 1 Female    5     -7.03
#>  7 Draw 1 Female    6     -7.12
#>  8 Draw 1 Female    7     -7.21
#>  9 Draw 1 Female    8     -7.27
#> 10 Draw 1 Female    9     -7.34
#> # ℹ 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.87
#>  2 Draw 1 1-4    -8.44
#>  3 Draw 1 5-9    -9.79
#>  4 Draw 1 10-14 -10.0 
#>  5 Draw 1 15-19  -9.11
#>  6 Draw 1 20-24  -8.65
#>  7 Draw 1 25-29  -8.55
#>  8 Draw 1 30-34  -8.33
#>  9 Draw 1 35-39  -7.99
#> 10 Draw 1 40-44  -7.55
#> # ℹ 270 more rows