SIM

<< Click to Display Table of Contents >>

Navigation:  Gekko commands >

SIM

Previous pageReturn to chapter overviewNext page

SIM solves the model dynamically, i.e. lagged endogenous variables use simulated values. The simulated values are placed in the first-position bank, thereby overwriting previous values of the endogenous variables. The default solving method is Gauss-Seidel. If Gauss-Seidel poses problems, for instance because of bad values in some of the variables, you may try setting OPTION solve failsafe = yes;. This will pinpoint the exact time period and variable that first produces an invalid value. Failsafe has a small speed overhead. For harder problems, you may need to use the Newton method.

 

You may solve goals/means by indicating these with the ENDO/EXO commands. The Newton method is used in that case, but please note that you need to use SIM<fix> in order for such goals/means to bind. When goals are removed later on (UNFIX command), the solve method reverts to Gauss-Seidel.

 

SIM may also solve a model with leaded endogenous variables. The Fair-Taylor ('fair') method is used in that case, or you may use the more powerful Newton-Fair-Taylor (called 'nfair' in Gekko). See the OPTION solve forward method = ....

 

Gekko will try to calculate some reasonable starting values for the endogenous variables, by means of looking at lagged values regarding these. If you wish to use the current (non-lagged) values as starting values, you should use OPTION solve data init = no;. For static models (for instance CGE models) that are simulated over a single time period, init = no should be used.

 

 


 

Syntax

 

SIM < period  FIX  STATIC  RES  AFTER >;

 

period

(Optional). Local period, for instance 2010 2020, 2010q1 2020q4 or %per1 %per2+1.

FIX

Tells Gekko to enforce any goals/means stated by the ENDO/EXO commands. It is mandatory to use SIM<fix> in such cases (if a normal SIM is used, the goals/means are ignored).

STATIC

Changes in endogenous variables are not transferred from period to period via lags. See also the OPTION solve static = yes.

RES

The SIM<res> command (residual check) performs a one-step-ahead static single-equation simulation of the entire model, i.e. the result of one equation does not affect other equations, nor does results of previous periods affect following periods.

 

The difference between actual historical values and a static single equation solutions are the equation residuals. Residuals are used to measure how well the model equations forecasts historically. SIM<res> is widely used for testing historical data against the model, or for testing a model against a historical databank. Gekko offers functionality to print results to files for subsequent inspection. See the menu item 'Utilities' --> 'Check residuals…' (output is grouped according to formula codes and/or model sections, and can be ordered).

AFTER

SIM<after> calculates three kinds of variables: (a) those designated with a formula beginning with ‘Y’, (b) all auto-generated variables of J- and Z-type, and (c) all table variables (variables defined after the AFTER; or AFTER$ line in a model file).

 

Since Y-type variables are typically also J- and Z-variables, one can think of SIM<after> as a way to compute all reversed J- and Z-variables independently of the SIM command (the SIM command computes these after simulation), in addition to computing table variables. See the MODEL command for more on J- and Z-variables.

 

On a well-specified model, reading a historical databank, and issuing a SIM<after> statement on the historical period should ideally make it possible to simulate on the historical period and replicate the endogenous variables.

 

If no period is given inside the <...> angle brackets, the global period is used (cf. TIME).

 

 


 

Examples

 

To increase all exogenious prices by 1% in 2011-2020, and inspect the effects on private consumption (pcp) and wages (lna):

 

READ lang11;
#pm = pm01, pm2, pm3r, pm59, pm7b, pm7y, pms, pmt;
#pe = pee2, pee59, peet, peesq;
TIME 2011 2020;
{#pm} *= 1.01;
{#pe} *= 1.01;
SIM;
MULPRT pcp, lna;

 

The result shows the difference between the values after simulation (first-position bank) and values in the reference databank (lang11.gbk) for the variables pcp and lna. Here, it is assumed that lang11 already is simulated over the period 2011-20.

 

If you need to solve goals/means, you can use the ENDO and EXO commands to change status of exogenous and endogenous variables, and perform a SIM afterwards. In that case, the solve method will be automatically changed to the Newton algorithm (and changed back if the goals/means are removed).

 

There are many options regarding SIM: please see under OPTION (in the OPTION solve ... section). Or type OPTION solve ?;. A single-equation static simulation can be performed with the SIM<res> command (for instance to check historical residuals).

 

If you want to change to the Newton algorithm manually, you can use OPTION solve method = newton;. It typically runs a bit slower, but is generally much more robust (and precise). With OPTION newton robust = yes, the Newton method activates a remedy against illegal starting values, like the logarithm to a negative number etc.

 

Static simulation (one period does not affect the next period) can be obtained by setting OPTION static = yes.

 

 


 

Related options

 

See the OPTION help page for details.

 

OPTION solve data create auto = yes; [yes|no]

OPTION solve data ignoremissing = no; [yes|no]

OPTION solve data init = yes; [yes|no]

OPTION solve data init growth = yes; [yes|no]

OPTION solve data init growth min = -0.02;

OPTION solve data init growth max = 0.06;

OPTION solve failsafe = no; [yes|no]

OPTION solve forward dump = no; [yes|no]

OPTION solve forward fair conv = conv1; [conv1|conv2]

OPTION solve forward fair conv1 rel = 0.0001;

OPTION solve forward fair conv1 abs = 0.0001;

OPTION solve forward fair conv2 trel = 0.0001;

OPTION solve forward fair conv2 tabs = 1.0;

OPTION solve forward fair damp = 0.0;

OPTION solve forward method = fair; [fair| nfair | none]

OPTION solve forward fair itermax = 200;

OPTION solve forward fair itermin = 10;

OPTION solve forward method = fair; [fair | nfair];

OPTION solve forward nfair conv = conv1; [conv1|conv2]

OPTION solve forward nfair conv1 rel = 0.001;

OPTION solve forward nfair conv1 abs = 0.001;

OPTION solve forward nfair conv2 trel = 0.001;

OPTION solve forward nfair conv2 tabs = 1.0;

OPTION solve forward nfair damp = 0.0;

OPTION solve forward nfair itermax = 200;

OPTION solve forward nfair itermin = 0;

OPTION solve forward nfair updatefreq = 200;

OPTION solve forward stacked horizon = 5;

OPTION solve forward terminal = const; [const|growth|none]

OPTION solve forward terminal feed = internal; [internal|external]

OPTION solve gauss conv = conv1;

OPTION solve gauss conv1 rel = 0.0001;

OPTION solve gauss conv1 abs = 0.0001;

OPTION solve gauss conv2 trel = 0.0001;

OPTION solve gauss conv2 tabs = 1.0;

OPTION solve gauss conv ignorevars = yes; [yes|no]

OPTION solve gauss damp = 0.5;

OPTION solve gauss dump = no; [yes|no]

OPTION solve gauss itermax = 200;

OPTION solve gauss itermin = 10;

OPTION solve gauss reorder = no; [yes|no]

OPTION solve method = gauss; [gauss|newton]

OPTION solve newton backtrack = yes; [yes|no]

OPTION solve newton conv abs = 0.0001;

OPTION solve newton invert = lu; [lu|iter]

OPTION solve newton itermax = 200;

OPTION solve newton robust = yes; [yes|no]

OPTION solve newton updatefreq = 15;

OPTION solve print details = no; [yes|no]

OPTION solve print iter = no; [yes|no]

OPTION solve static = no; [yes|no]

 

 


 

Related commands

 

MODEL, EXO, ENDO, READ, WRITE, CLONE, MULPRT