iode.Equation.estimate

Equation.estimate(from_period: str | Period = None, to_period: str | Period = None, maxit: int = 100, epsilon: float = 1e-06, quiet: bool = False) bool[source]

Estimate the present equation.

At the end of the estimation process, certain variables and scalars are automatically created if the process has converged. These variables and scalars can be used for computational purposes and, as they are part of the global workspace, can be saved for future use.

The tests resulting from the last estimation are saved as scalars. The same applies to residuals, left-hand and right-hand members of equations.

Saved tests (as scalars) have the following names:

  • e0_n : number of sample periods

  • e0_k : number of estimated coefficients

  • e0_stdev : std dev of residuals

  • e0_meany : mean of Y

  • e0_ssres : sum of squares of residuals

  • e0_stderr : std error

  • e0_stderrp : std error percent (in %)

  • e0_fstat : F-Stat

  • e0_r2 : R square

  • e0_r2adj : adjusted R-squared

  • e0_dw : Durbin-Watson

  • e0_loglik : Log Likelihood

Calculated series are saved in special variables:

  • _YCALC0 : right-hand side of the equation

  • _YOBS0 : left-hand side of the equation

  • _YRES0 : residuals of the equation

Outside the estimation sample, the series values are \(NA\).

Parameters:
from_periodstr or Period, optional

The starting period of the execution range. Defaults to the starting period of the current Variables sample.

to_periodstr or Period, optional

The ending period of the execution range. Defaults to the ending period of the current Variables sample.

maxitint, optional

The maximum number of iterations for the estimation process. Defaults to 100.

epsilonfloat, optional

The convergence threshold for the estimation process. Defaults to 1.0e-6.

quietbool, optional

If True, suppresses the log messages during the estimation process. Default to False.

Returns:
bool

True if the estimation process has converged, False otherwise.

Warning

If the present equation belongs to a block, you must use the Equations.estimate() method instead.

Examples

>>> from iode import SAMPLE_DATA_DIR, equations, scalars, variables, Equation
>>> equations.load(f"{SAMPLE_DATA_DIR}/fun.eqs")
Loading .../fun.eqs
274 objects loaded 
>>> variables.load(f"{SAMPLE_DATA_DIR}/fun.var")
Loading .../fun.var
394 objects loaded
>>> eq_ACAF = Equation("ACAF", "(ACAF / VAF[-1]) := acaf1 + acaf2 * GOSF[-1] + acaf4 * (TIME=1995)")
>>> eq_ACAF.lec
'(ACAF / VAF[-1]) := acaf1 + acaf2 * GOSF[-1] + acaf4 * (TIME=1995)'
>>> # create scalars
>>> scalars["acaf1"] = 0., 1.
>>> scalars["acaf2"] = 0., 1.
>>> scalars["acaf4"] = 0., 1.
>>> # estimate the ACAF equation
>>> success = eq_ACAF.estimate("1980Y1", "2000Y1") 
Estimating : iteration 1 (||eps|| = 0.173205)
Estimating : iteration 2 (||eps|| = 9.24137e-09)
Solution reached after 2 iteration(s). Creating results file ...
>>> success
True
>>> scalars["acaf1"]
Scalar(0.0150646, 1, 0.00118455)
>>> scalars["acaf2"]
Scalar(-6.90855e-06, 1, 1.07873e-06)
>>> scalars["acaf4"]
Scalar(-0.00915675, 1, 0.00209541)
>>> eq_ACAF
Equation(endogenous = 'ACAF',
        lec = '(ACAF / VAF[-1]) := acaf1 + acaf2 * GOSF[-1] + acaf4 * (TIME=1995)',
        method = 'LSQ',
        from_period = '1980Y1',
        to_period = '2000Y1',
        tests = {corr = 1,
                 dw = 1.87449,
                 fstat = 34.6629,
                 loglik = 102.07,
                 meany = 0.0075289,
                 r2 = 0.793875,
                 r2adj = 0.770973,
                 ssres = 7.37883e-05,
                 stderr = 0.00202468,
                 stderrp = 26.8922,
                 stdev = 0.00423072},
        date = '...')
>>> # observed values (left hand side of the equation)
>>> variables["_YOBS0", "1980Y1:2000Y1"]
Workspace: Variables
nb variables: 1
filename: ...fun.var
description: Modèle fun - Simulation 1
sample: 1980Y1:2000Y1
mode: LEVEL

 name      1980Y1  1981Y1  1982Y1  ...  1998Y1  1999Y1  2000Y1
_YOBS0       0.01    0.02    0.01  ...    0.01    0.00    0.00

>>> # fitted values (right hand side of the equation)
>>> variables["_YCALC0", "1980Y1:2000Y1"]
Workspace: Variables
nb variables: 1
filename: ...fun.var
description: Modèle fun - Simulation 1
sample: 1980Y1:2000Y1
mode: LEVEL

  name     1980Y1  1981Y1  1982Y1  ...  1998Y1  1999Y1  2000Y1
_YCALC0      0.01    0.01    0.01  ...    0.00    0.00    0.00

>>> # residuals values
>>> variables["_YRES0", "1980Y1:2000Y1"]
Workspace: Variables
nb variables: 1
filename: ...fun.var
description: Modèle fun - Simulation 1
sample: 1980Y1:2000Y1
mode: LEVEL

 name      1980Y1  1981Y1  1982Y1  ...  1998Y1  1999Y1  2000Y1
_YRES0      -0.00    0.00   -0.00  ...    0.00   -0.00   -0.00