To run projections with {propop}
, you need a starting
population and projection parameters. You can of course use your own
data but you need to ensure that the input files have the required
structure. If you don’t have the relevant data, you can download them
from the Federal Statistical Office (FSO). This vignette explains how to
get the data. You’ll also learn how to prepare the relevant information
to run population projections {propop}
.
Note that some data are only available for certain administrative levels.
If you don’t have the information and data required to run
propop::propop()
(or propop::project_raw()
),
you can download most of the data from STAT-TAB. More
specifically, the information from the following tables are needed:
Table ID | Parameters expressed as… | Variables required for projection |
---|---|---|
px- x-0104020000_101 | number of people (reference scenario) |
|
px- x-0104020000_102 | number of people (high growth scenario) |
|
px- x-0104020000_103 | number of people (low growth scenario) |
|
px- x-0104020000_109 | rates / probabilities (five scenarios) |
|
px -x-0104020000_106 | share of newborns with Swiss nationality born to non-Swiss mothers |
|
Constant parameters not directly available from STAT-TAB are provided as arguments |
|
The propop
package provides two convenience functions to
download data from the FSO. These are strongly based on the
BFS
package and its documentation.
To get the starting population for a spatial unit, you must use the spelling defined in the corresponding FSO table. The entries in the FSO tables may contain special characters. The spelling may also vary between FSO tables.
BFS::bfs_get_metadata()
is helpful to identify the
required spelling(s).
Here’s an example of how to get the population for the canton of Aargau:
library(propop)
ag_population <- get_population(
number_fso = "px-x-0102010000_101",
year = 2022,
spatial_units = "- Aargau"
)
Get the parameters for a sample canton (mind using the same spelling as in the FSO tables; see comment above):
The projection can be run as follows:
# select reference scenario
ag_parameters_ref <- ag_parameters |>
dplyr::filter(scen == "reference")
propop(
parameters = ag_parameters_ref,
year = 2023,
year_last = 2026,
age_groups = 101,
fert_first = 16,
fert_last = 50,
share_born_female = 100 / 205,
population = ag_population,
subregional = FALSE,
binational = TRUE
)
Note of caution: As long as the FSO’s API interface and the underlying data structure remain stable, the functions will work. However, changes in the API are likely to break the functions.