scale.pop.prediction: Population Scaling To Match Aggregated Targets

pop.scale.predictionR Documentation

Population Scaling To Match Aggregated Targets

Description

Functions scale given sex- and age-specific population counts for each location and year, so that the sum of the scaled counts over all locations matches the given target for each year, sex and age. Function scale.pop.prediction creates a new prediction object that contain the scaled trajectories. Function write.scaled.pop writes a file containing the scaled statistics for each location, year, sex and age.

Usage

pop.scale.prediction(pop.pred, target.file, output.dir,
    target.code = NULL, variant.name = "mean", 
    target.id.column = "country_code", stat = "mean", 
    exclude.codes = NULL, verbose = TRUE)
    
write.scaled.pop(pop.pred, target.file, 
    output.file = "adjusted_population.txt", target.code = NULL, 
    variant.name = "mean", target.id.column = "country_code", 
    output.id.column = "reg_code", stat = "mean", 
    exclude.codes = NULL, verbose = TRUE)

Arguments

pop.pred

Object of class bayesPop.prediction containing population projections to be scaled.

target.file

Comma-delimited file containing the summary statistics of the aggregated targets. For example, if locations in pop.pred are states, this file would contain the summary statistics for the corresponding country. It is expected to have the same format as a file created with write.pop.projection.summary(what = 'popsexage'). That is, it should have the following columns: country_code (unique identifier of the aggregated locations), sex (either “male” or “female”), age (values from 0 to 130), columns for each year or time period. Optionally, column variant can be present.

output.dir

Directory to write the scaled projection into.

target.code

If the target.file contains more than one aggregated location, this argument gives the code of the location to use.

variant.name

If the target.file contains the column variant, this argument gives the value of that column for selecting the summary statistics. If the target.file is created via the write.pop.projection.summary function, run it with the argument include.means = TRUE to generate a file with the “mean” variant, which is the default value here.

target.id.column

Name of the column in target.file that determines the unique identifiers of the aggregated locations.

stat

Summary statistics to use for the scaling. By default, the scaling shifts are determined by comparing the means of the trajectories with the targets.

exclude.codes

Vector of location codes that should be excluded from the scaling.

output.file

File name to write the scaled sumary statistics into.

output.id.column

Column name of the unique identifier of the locations in the output file.

verbose

Logical switching processing info on and off.

Details

These functions can be used if it is necessary to scale the population distribution so that a summary statistics of the sum of the locations matches some given targets. For example, if states should sum up to a given country projection. Thus, its use is meant to be mainly for subnational projections.

The scaling is done for each sex and age, and the scaling proportions are determined by the population sizes within each sex and age group.

The function scale.pop.prediction creates a new prediction object, saved into the directory given by output.dir. It contains adjusted population trajectories, as well as recomputed quantiles. Note however that only population quantities are affected by this scaling. There is no change to vital events or rates.

Function write.scaled.pop derives the necessary shifts for the scaling and stores the adjusted summary statistics into a file. It does not create any new projection object.

Value

Function scale.pop.prediction returns an object of class bayesPop.prediction containing the scaled predictions. Function write.scaled.pop returns the name of the file that it created.

Author(s)

Hana Sevcikova


PPgp/bayesPop documentation built on June 9, 2025, 12:37 p.m.