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.

...

Not currently used.

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
#>    <int> <chr> <dbl>
#>  1     1 0     -3.77
#>  2     1 1     -5.88
#>  3     1 2     -6.36
#>  4     1 3     -6.60
#>  5     1 4     -6.77
#>  6     1 5     -6.88
#>  7     1 6     -6.97
#>  8     1 7     -7.04
#>  9     1 8     -7.10
#> 10     1 9     -7.15
#> # ℹ 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     -3.01
#>  2     1 Female    1     -4.87
#>  3     1 Female    2     -5.71
#>  4     1 Female    3     -6.24
#>  5     1 Female    4     -6.63
#>  6     1 Female    5     -6.94
#>  7     1 Female    6     -7.23
#>  8     1 Female    7     -7.49
#>  9     1 Female    8     -7.72
#> 10     1 Female    9     -7.91
#> # ℹ 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.43
#>  2     1 1-4   -6.08
#>  3     1 5-9   -7.34
#>  4     1 10-14 -7.65
#>  5     1 15-19 -6.99
#>  6     1 20-24 -6.61
#>  7     1 25-29 -6.56
#>  8     1 30-34 -6.44
#>  9     1 35-39 -6.22
#> 10     1 40-44 -5.94
#> # ℹ 270 more rows