Package 'propopbirth'

Title: Birth rate forecast based on the FSO methodology
Description: First, model input data are calculated. Second, TFR (total fertility rate) and MAB (mean age of the mother at birth) are predicted. Third, TFR and MAB forecasts are used to predict the age-specific birth rates.
Authors: Klemens Rosin [aut], Felix Lorenz [aut], Norah Efosa [aut, cre], Felix Luginbuhl [ctb] (ORCID: <https://orcid.org/0009-0008-6625-2899>)
Maintainer: Norah Efosa <[email protected]>
License: GPL (>= 3)
Version: 0.1.0
Built: 2026-06-05 07:17:52 UTC
Source: https://github.com/statistik-aargau/propopbirth

Help Index


Create model input data

Description

Create model input data

Usage

create_input_data(
  population,
  births,
  year_first,
  year_last,
  age_fert_min,
  age_fert_max,
  fert_hist_years,
  binational = TRUE,
  digits_tfr = 3,
  digits_mab = 3,
  digits_fer = 5
)

Arguments

population

data frame, female population at 'fertile age'; columns: spatial_unit, year, age, pop, with or without nat (nationality).

births

data frame, births of females in the fertile age range; columns: spatial_unit, year, age, pop, with or without nat (nationality).

year_first

numeric, first year.

year_last

numeric, last year.

age_fert_min

numeric, minimum age (of 'fertile age').

age_fert_max

numeric, minimum age (of 'fertile age').

fert_hist_years

how many years are used to calculate age-specific fertility rates?

binational

boolean, TRUE indicates that projections discriminate between two groups of nationalities. FALSE indicates that the projection is run without distinguishing between nationalities.

digits_tfr

numeric, number of digits for tfr (total fertility rate).

digits_mab

numeric, number of digits for mab (mean age of the mother at birth).

digits_fer

numeric, number of digits for the fertility rate.

Value

list with:

  • tfr (total fertility rate),

  • mab (mean age of the mother at birth),

  • fer (fertility rate of last year(s))

Examples

create_input_data(
  population = fso_pop,
  births = fso_birth |>
    dplyr::filter(spatial_unit %in% c("Stadt Zuerich", "Frauenfeld", "Aarau")),
  year_first = 2011,
  year_last = 2023,
  age_fert_min = 15,
  age_fert_max = 49,
  fert_hist_years = 1,
  binational = TRUE
)

Forecast age-specific fertility rates.

Description

Forecast age-specific fertility rates.

Usage

forecast_fertility_rate(
  fer_dat,
  tfr_dat,
  mab_dat,
  year_start,
  year_end,
  maxit = 1000,
  abstol = 0.001,
  digits_birth_rate = 5
)

Arguments

fer_dat

data frame, fertility data, tibble with variables spatial_unit, nat, age, fer.

tfr_dat

tfr data, tibble with variables spatial_unit, nat, year, tfr.

mab_dat

mab data, tibble with variables spatial_unit, nat, year, mab.

year_start

numeric, start of prediction.

year_end

numeric, end of prediction.

maxit

numeric, maximum iterations of optimization.

abstol

numeric, absolute tolerance of optimization.

digits_birth_rate

numeric, number of digits of the birth rate.

Value

birth rate, tibble with variables spatial_unit, nat, age, birth_rate.


Forecast total fertility rate (TFR) or mean age of the mother at birth (MAB)

Description

Forecast total fertility rate (TFR) or mean age of the mother at birth (MAB)

Usage

forecast_tfr_mab(
  topic,
  topic_data,
  trend_model,
  temporal_model,
  temporal_end = NA,
  constant_model
)

Arguments

topic

character, defines the parameter to calculate (tfr or mab).

topic_data

data frame, input data tailored to the topic with variables: spatial_unit, nat, year, either tfr or mab. This data is obtained by the function create_input_data(). Columns for spatial_unit and/or nat are optional.

trend_model

vector, specifies the model type (ARIMA or lm), the first (start) and last (end) year. If an lm model is used, the window of past years (trend_past) and the proportional amount of past years used to fit the model (trend_prop) can be specified.

temporal_model

vector, model type (cubic, Bezier or constant), first and last year, proportion of trend (trend_prop), proportion for slopes (z0_prop) and proportion of the slope at the end point (z1_prop).

temporal_end

data frame, contains y-values at the end of the temporal forecast period (y_end).

constant_model

model type (constant), first and last year.

Value

data frame, predictions for either tfr or mab.


FSO data for births

Description

Data was retrieved from the FSO.

Usage

fso_birth

Format

A data frame with 437054 rows and 5 variables:

year

year within the range 2010-2023

spatial_unit

Swiss municipalities by name

nat

Nationality; either "ch" = Swiss or "int" = international

age

Age in full years

n_birth

number of births

Examples

dplyr::glimpse(fso_birth)

Population data from the Federal Statistical Office

Description

End year population from different spatial units.

Usage

fso_pop

Format

An object of class tbl_df (inherits from tbl, data.frame) with 2940 rows and 5 columns.


Get FSO population (females at 'fertile' age)

Description

Get FSO population (females at 'fertile' age)

Usage

get_population_data(
  number_fso,
  year_first,
  year_last,
  age_fert_min,
  age_fert_max,
  spatial_code,
  spatial_unit,
  binational = TRUE
)

Arguments

number_fso

character, number of FSO table (STAT-TAB)

year_first

numeric, first year.

year_last

numeric, last year.

age_fert_min

numeric, minimum age (of 'fertile age').

age_fert_max

numeric, maximum age (of 'fertile age').

spatial_code

character, vector, official FSO codes.

spatial_unit

character, vector, spatial unit names (free choice).

binational

boolean, TRUE indicates that projections discriminate between two groups of nationalities. FALSE indicates that the projection is run without distinguishing between nationalities.

Value

female population at 'fertile age' at the end of the year, tibble (spatial_unit, year, age, pop), with or without nat (nationality)

Examples

get_population_data(
  number_fso = "px-x-0102010000_101",
  year_first = 2020,
  year_last = 2023,
  age_fert_min = 15,
  age_fert_max = 49,
  spatial_code = c("0261", "4566", "4001"),
  spatial_unit = c("Stadt Zuerich", "Frauenfeld", "Aarau"),
  binational = TRUE
)