iode.Variables.extrapolate
- Variables.extrapolate(self, method: SimulationInitialization | str, from_period: str | Period = None, to_period: str | Period = None, variables_list: str | List[str] = None)
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"] [0.0, 1.0, 2.0, 3.0, 4.0, -2e+37, 6.0, -2e+37, 8.0, 9.0, 10.0]
>>> # "TM1" (Y := Y[-1], if Y null or NA) >>> reset_ACAF() >>> variables.extrapolate(SimulationInitialization.TM1, "2005Y1", "2010Y1") >>> variables["ACAF", "2003Y1":"2009Y1"] [3.0, 4.0, 4.0, 6.0, 6.0, 8.0, 9.0]
>>> # "TM1_A" (Y := Y[-1], always) >>> reset_ACAF() >>> variables.extrapolate(SimulationInitialization.TM1_A, "2005Y1", "2010Y1") >>> variables["ACAF", "2003Y1":"2009Y1"] [3.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]
>>> # "EXTRA" (Y := extrapolation, if Y null or NA) >>> reset_ACAF() >>> variables.extrapolate(SimulationInitialization.EXTRA, "2005Y1", "2010Y1") >>> variables["ACAF", "2003Y1":"2009Y1"] [3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
>>> # "EXTRA_A" (Y := extrapolation, always) >>> reset_ACAF() >>> variables.extrapolate(SimulationInitialization.EXTRA_A, "2005Y1", "2010Y1") >>> variables["ACAF", "2003Y1":"2009Y1"] [3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
>>> # "ASIS" (Y unchanged) >>> reset_ACAF() >>> variables.extrapolate(SimulationInitialization.ASIS, "2005Y1", "2010Y1") >>> variables["ACAF", "2003Y1":"2009Y1"] [3.0, 4.0, -2e+37, 6.0, -2e+37, 8.0, 9.0]
>>> # "TM1_NA" (Y := Y[-1], if Y = NA) >>> reset_ACAF() >>> variables.extrapolate(SimulationInitialization.TM1_NA, "2005Y1", "2010Y1") >>> variables["ACAF", "2003Y1":"2009Y1"] [3.0, 4.0, 4.0, 6.0, 6.0, 8.0, 9.0]
>>> # "EXTRA_NA" (Y := extrapolation, if Y = NA) >>> reset_ACAF() >>> variables.extrapolate(SimulationInitialization.EXTRA_NA, "2005Y1", "2010Y1") >>> variables["ACAF", "2003Y1":"2009Y1"] [3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]