mig.adjust: Adjusting the Projection Medians

mig.median.setR Documentation

Adjusting the Projection Medians

Description

These functions are to be used by expert analysts. They allow to change the projection medians either to specific values, or shift the medians by a given constant or align one projection object with another.

Usage

mig.median.set(sim.dir, country, values, years = NULL, ...)

mig.median.shift(
  sim.dir,
  country,
  reset = FALSE,
  shift = 0,
  from = NULL,
  to = NULL
)

mig.median.reset(sim.dir, countries = NULL)

mig.align.predictions(
  sim.dir1,
  sim.dir2,
  country.codes = NULL,
  years = NULL,
  ...
)

mig.shift.prediction.to.wpp(sim.dir, ...)

Arguments

sim.dir

Directory containing the prediction object.

country

Name or numerical code of a country.

values

Vector of the new median values.

years

Numeric vector giving years for which to change the median. In mig.median.set it gives years which values correspond to. Ideally it should be of the same length as values. If it is NULL, values are set starting from the first prediction time period. If values correspond to consecutive years, only the first year might be given here. In mig.align.predictions it gives years for which the medians should be aligned.

...

Additional arguments passed to the underlying adjustment functions, such as verbose to show/hide the progress of the adjustment. For mig.shift.prediction.to.wpp it can be stat with values “median” (default) or “mean” to specify which statistics should be adjusted; wpp.year to adjust it to if it differs from the wpp year of the simulation.

reset

Logical. If TRUE medians in a range of from and to are reset to their original values.

shift

Constant by which the medians should be offset. It is not used if reset is TRUE.

from

Year from which the offset/reset should start. By default, it starts at the first prediction period.

to

Year until which the offset/reset should be done. By default, it is set to the last prediction period.

countries

Vector of country names or codes. If this argument is NULL (default), the reset is done for all countries.

sim.dir1

Directory with the bayesMig prediction object to be adjusted.

sim.dir2

Directory with the bayesMig prediction object used to align the medians from sim.dir1 to.

country.codes

Numerical codes of countries to adjust. By default all countries found in sim.dir2 are adjusted in sim.dir1.

Details

The function mig.median.set can be used to set the medians of the given country to specific values.

Function mig.median.shift can be used to offset the medians by a specific constant, or to reset the medians to their original values.

Function mig.median.reset resets medians of the given countries to the original values. By default it deletes adjustments for all countries.

Function mig.align.predictions shifts medians stored in sim.dir1 to match the medians in sim.dir1.

In all cases, if a median is modified, the corresponding offset is stored in the prediction object (element median.shift). All functions write the updated prediction object back to disk. All functions in the package that use trajectories and trajectory statistics use the median.shift values to offset the results correspondingly, i.e. trajectories are shifted the same way as the medians.

Function mig.shift.prediction.to.wpp shifts the projected medians or means (if stat is “mean”), so that they correspond to the values found in the migproj1dt or migproj5dt datasets of the wpp package that either corresponds to the package used for the simulation itself or is given by the wpp.year argument. Currently, the function only works for wpp2024. Note that regardless if it is an adjustment of the median or mean, the corresponding offset is always converted to a shift of the median.

Value

All functions return an updated object of class bayesMig.prediction.


bayesMig documentation built on April 3, 2025, 8:59 p.m.