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.63
#>  2 Draw 1 1     -5.58
#>  3 Draw 1 2     -6.09
#>  4 Draw 1 3     -6.37
#>  5 Draw 1 4     -6.56
#>  6 Draw 1 5     -6.69
#>  7 Draw 1 6     -6.80
#>  8 Draw 1 7     -6.89
#>  9 Draw 1 8     -6.97
#> 10 Draw 1 9     -7.03
#> # ℹ 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.99
#>  2 Draw 1 Female    1     -6.49
#>  3 Draw 1 Female    2     -6.89
#>  4 Draw 1 Female    3     -7.02
#>  5 Draw 1 Female    4     -7.10
#>  6 Draw 1 Female    5     -7.17
#>  7 Draw 1 Female    6     -7.19
#>  8 Draw 1 Female    7     -7.20
#>  9 Draw 1 Female    8     -7.17
#> 10 Draw 1 Female    9     -7.22
#> # ℹ 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.14
#>  2 Draw 1 1-4   -7.02
#>  3 Draw 1 5-9   -7.67
#>  4 Draw 1 10-14 -7.69
#>  5 Draw 1 15-19 -6.89
#>  6 Draw 1 20-24 -6.60
#>  7 Draw 1 25-29 -6.47
#>  8 Draw 1 30-34 -6.21
#>  9 Draw 1 35-39 -5.85
#> 10 Draw 1 40-44 -5.42
#> # ℹ 270 more rows