Learn R Programming

bayesPop (version 11.0-2)

peak.probability: Probability of Peaks in Population Indicators

Description

For a given indicator and a country, the function computes the probability of a peak happening before a given year, as well as a range of years between which a peak happens with given probability.

Usage

peak.probability(pop.pred, country = NULL, expression = NULL, year = NULL, 
    pi = 95, verbose = TRUE, ...)

Value

List with elements:

prob.peak.less.given.year

Probability that the indicator reaches its peak before year.

given.year

The value of year.

peak.quantiles

The lower bound, the upper bound and the median of years defining a time interval in which a peak happens with the given probability pi

.

all.prob.peak.by.time

Data frame containing the probability of peak happening in each projected year, as well as the corresponding cummulative probability. Years in which no peak is projected are not included.

Arguments

pop.pred

Object of class bayesPop.prediction.

country

Name or numerical code or ISO-2 or ISO-3 character code of a country. If given, population is used as an indicator and the expression argument is ignored.

expression

Expression defining an indicator. For syntax see pop.expressions. It must be defined by time (i.e. either without or with square brackets, and no curly braces). Only used if country is not speicified.

year

Used for computing the probability of a peak happenning before year.

pi

Probability between 0 and 100. Used for selecting a range of years between which a peak happens with probability given by this argument.

verbose

Logical. If TRUE, results are printed.

...

Additional arguments passed to the underlying functions. If country is given, these are arguments passed to pop.trajectories, e.g. sex, age or adjust. If the indicator is given via expression, it can be e.g. adj.to.file.

Author

Hana Sevcikova

Details

Given an indicator, the function computes two quantities:

  • probability that the indicator reaches its peak before given year;

  • range of years between which a peak happens with the given probability pi.

The indicator can be either population (if country is given), or it can be any expression defined as a function of time (see pop.expressions).

See Also

pop.expressions

Examples

Run this code
sim.dir <- file.path(find.package("bayesPop"), "ex-data", "Pop")
pred <- get.pop.prediction(sim.dir, write.to.cache=FALSE)

# probability that population of Netherlands peaks before 2040 
# and between which years it will peak with probablity 80%
peak.probability(pred, "NL", year = 2040, pi = 80)

# check visually with  
# pop.trajectories.plot(pred, "NL")

# the same for female of age 45-49
peak.probability(pred, "NL", year = 2040, pi = 80, sex = "female", age = 10)

# probability of a peak for the potential support ratio in Ecuador
peak.probability(pred, expression = "PEC[5:13]/PEC[14:27]")

# check visually that it already peaked
# pop.trajectories.plot(pred, expression = "PEC[5:13]/PEC[14:27]")

Run the code above in your browser using DataLab