iode.Variables.extrapolate

Variables.extrapolate(method: SimulationInitialization | str, from_period: str | Period = None, to_period: str | Period = None, variables_list: str | List[str] = None)[source]

Extrapolate variables using one the method described below, based on previous periods.

The possible methods are as follows:

  • \(Y := Y[-1], if Y null or NA\) (TM1) : each null or NA endogen at the start takes the value of the previous period,

  • \(Y := Y[-1], always\) (TM1_A) : each endogen takes the value of the previous period at the start,

  • \(Y := extrapolation, if Y null or NA\) (EXTRA) : each null or NA endogen takes as value a linear extrapolation of the two previous periods,

  • \(Y := extrapolation, always\) (EXTRA_A) : each endogen takes as its value a linear extrapolation of the two preceding periods, whether or not it is zero at the start,

  • \(Y unchanged\) (ASIS): endogenous values are not initialized. They retain their value whether or not they are zero,

  • \(Y := Y[-1], if Y = NA\) (TM1_NA): each NA value takes the value of the previous period,

  • \(Y := extrapolation, if Y = NA\) (extra_na): each NA value takes the value of a linear extrapolation of the two previous periods.

The sample over which the calculation is to be performed must be supplied. This sample must be a sub-sample of the global sample defined in the current Variables database.

In addition, the list of variables to be extrapolated can be specified. If this list is not given, all variables will be extrapolated.

Parameters:
method: SimulationInitialization or str
initialization method. Possible values are:
  • TM1: \(Y := Y[-1], if Y null or NA\)

  • TM1_A: \(Y := Y[-1], always\)

  • EXTRA: \(Y := extrapolation, if Y null or NA\)

  • EXTRA_A: \(Y := extrapolation, always\)

  • ASIS: \(Y unchanged\)

  • TM1_NA: \(Y := Y[-1], if Y = NA\)

  • EXTRA_NA: \(Y := extrapolation, if Y = NA\)

from_period: str or Period, optional

starting period to extrapolate variables. Defaults to the starting period if the current sample.

to_period: str or Period, optional

ending period to extrapolate variables. Defaults to the ending period if the current sample.

variables_list: str or list(str), optional

list of variables to extrapolate. Defaults to None (all variables).

Examples

>>> from iode import variables, NA, SimulationInitialization
>>> variables.clear()
>>> variables.sample = "2000Y1:2020Y1"
>>> def reset_ACAF():
...     variables["ACAF"] = "t"
...     variables["ACAF", ["2005Y1", "2007Y1"]] = NA
>>> # create ACAF
>>> reset_ACAF()
>>> variables["ACAF", :"2010Y1"]
Workspace: Variables
nb variables: 1
filename: ws
sample: 2000Y1:2010Y1
mode: LEVEL

name        2000Y1  2001Y1  2002Y1  2003Y1  2004Y1  2005Y1  2006Y1  2007Y1  2008Y1  2009Y1  2010Y1
ACAF          0.00    1.00    2.00    3.00    4.00      na    6.00      na    8.00    9.00   10.00
>>> # "TM1" (Y := Y[-1], if Y null or NA)
>>> reset_ACAF()
>>> variables.extrapolate(SimulationInitialization.TM1, "2005Y1", "2010Y1")
>>> variables["ACAF", "2003Y1":"2009Y1"]
Workspace: Variables
nb variables: 1
filename: ws
sample: 2003Y1:2009Y1
mode: LEVEL

name        2003Y1  2004Y1  2005Y1  2006Y1  2007Y1  2008Y1  2009Y1
ACAF          3.00    4.00    4.00    6.00    6.00    8.00    9.00
>>> # "TM1_A" (Y := Y[-1], always)
>>> reset_ACAF()
>>> variables.extrapolate(SimulationInitialization.TM1_A, "2005Y1", "2010Y1")
>>> variables["ACAF", "2003Y1":"2009Y1"]
Workspace: Variables
nb variables: 1
filename: ws
sample: 2003Y1:2009Y1
mode: LEVEL

name        2003Y1  2004Y1  2005Y1  2006Y1  2007Y1  2008Y1  2009Y1
ACAF          3.00    4.00    4.00    4.00    4.00    4.00    4.00
>>> # "EXTRA" (Y := extrapolation, if Y null or NA)
>>> reset_ACAF()
>>> variables.extrapolate(SimulationInitialization.EXTRA, "2005Y1", "2010Y1")
>>> variables["ACAF", "2003Y1":"2009Y1"]
Workspace: Variables
nb variables: 1
filename: ws
sample: 2003Y1:2009Y1
mode: LEVEL

name        2003Y1  2004Y1  2005Y1  2006Y1  2007Y1  2008Y1  2009Y1
ACAF          3.00    4.00    5.00    6.00    7.00    8.00    9.00
>>> # "EXTRA_A" (Y := extrapolation, always)
>>> reset_ACAF()
>>> variables.extrapolate(SimulationInitialization.EXTRA_A, "2005Y1", "2010Y1")
>>> variables["ACAF", "2003Y1":"2009Y1"]
Workspace: Variables
nb variables: 1
filename: ws
sample: 2003Y1:2009Y1
mode: LEVEL

name        2003Y1  2004Y1  2005Y1  2006Y1  2007Y1  2008Y1  2009Y1
ACAF          3.00    4.00    5.00    6.00    7.00    8.00    9.00
>>> # "ASIS" (Y unchanged)
>>> reset_ACAF()
>>> variables.extrapolate(SimulationInitialization.ASIS, "2005Y1", "2010Y1")
>>> variables["ACAF", "2003Y1":"2009Y1"]
Workspace: Variables
nb variables: 1
filename: ws
sample: 2003Y1:2009Y1
mode: LEVEL

name        2003Y1  2004Y1  2005Y1  2006Y1  2007Y1  2008Y1  2009Y1
ACAF          3.00    4.00      na    6.00      na    8.00    9.00
>>> # "TM1_NA" (Y := Y[-1], if Y = NA)
>>> reset_ACAF()
>>> variables.extrapolate(SimulationInitialization.TM1_NA, "2005Y1", "2010Y1")
>>> variables["ACAF", "2003Y1":"2009Y1"]
Workspace: Variables
nb variables: 1
filename: ws
sample: 2003Y1:2009Y1
mode: LEVEL

name        2003Y1  2004Y1  2005Y1  2006Y1  2007Y1  2008Y1  2009Y1
ACAF          3.00    4.00    4.00    6.00    6.00    8.00    9.00
>>> # "EXTRA_NA" (Y := extrapolation, if Y = NA)
>>> reset_ACAF()
>>> variables.extrapolate(SimulationInitialization.EXTRA_NA, "2005Y1", "2010Y1")
>>> variables["ACAF", "2003Y1":"2009Y1"]
Workspace: Variables
nb variables: 1
filename: ws
sample: 2003Y1:2009Y1
mode: LEVEL

name        2003Y1  2004Y1  2005Y1  2006Y1  2007Y1  2008Y1  2009Y1
ACAF          3.00    4.00    5.00    6.00    7.00    8.00    9.00