SimDesign

Overview

SimDesign

SimDesign summary

Constructor/destructor of SimDesign
SimDesign Constructor: sets client object and variable type identifiers.
~SimDesign Destructor.
Public member functions of SimDesign
AddExtrasToReference Override this virtual function to add additional terms to the reference model
AddImpulseBreakToRefPar Adds a break to a parameter vector formulated in terms of impulse dummies that are in the client database.
CreateDatabase Creates database for the DGP in the client object
CreateReference Creates the design, which is the reference model for the DGP and GUM
DummySaturation Saturates the client database with the specified dummies.
FormulateDGP Formulates the DGP model in the client object.
FormulateModel Formulates the model in the client object.
FormulateModelInReference Formulates a model in the client object with respect to the reference model.
FormulateReferenceModel Formulates the reference model in the client object.
Generate Generates X, u, y, Dy, stores them in the client database.
GenerateX Generates X.
GetARParInDGP
GetDGPno Gets the DGP number.
GetDgpParCount
GetObsCount
GetObsInitCount
GetRefConstantLabel
GetRefModelObject Gets the client object reference
GetRefParDGP
GetRefParNames
GetRefUParCount
GetSigmaInDGP
GetTitle Gets the title
IsModelDeltaY Returns TRUE if using Dy as dependent variable in FormulateModel, FALSE otherwise (default).
PreGenerate To be called after setting the initial seed (optional) for the experiment, but before starting the Monte Carlo loop.
RemoveFromModel Removes variables by name from the model.
SetDGP Sets the DGP parameters in terms of the reference model.
SetDGPError Sets the DGP error properties.
SetDGPno Sets the DGP number.
SetModel Sets the DGP parameters in terms of the reference model.
SetRenewX Set TRUE if data on X is to be renewed for every replication, FALSE otherwise.
SetTitle Sets the title
SetXAutoCorrelation
SetXCorrelation Creates a correlation matrix for X by setting rho.
TransformX1 X transformation immediately after drawing the N[0,1] terms.
TransformX2 X transformation after applying correlation (if any) to X.
UndoFormulateModelDeltaY Reformulates the model in the client object from Dy to y, and re-estimates.
UseModelDeltaY Set TRUE to use Dy as dependent variable in FormulateModel, FALSE otherwise.
Public enums of SimDesign
enum1 USE_CONSTANT_NONE, USE_CONSTANT_U, USE_CONSTANT_X
enum2 USE_XCOR_MATCONST, USE_XCOR_MATPOWIJ, USE_XCOR_AUTO
enum3 SAT_NONE, SAT_IIS, SAT_SIS, SAT_IIS_SIS
Protected data members of SimDesign
m_asDummy names of dummy saturation terms added to the database
m_asEps names of y, residual and regressors X created in m_oRefModel
m_asPar_RM names of the regressors of the reference model
m_asStep optional step dummies added by Create(), with names Step[#:#]
m_asX names of y, residual and regressors X created in m_oRefModel
m_asY names of y, residual and regressors X created in m_oRefModel
m_bHaveX TRUE if m_oRefModel has data on X
m_bModelDeltaY TRUE: using Dy as dependent variable in FormulateModel
m_bRenewX TRUE if data on X is to be renewed for every replication
m_bTrend_RM TRUE: Trend in GUM
m_cStep_RM no of step dummies in reference model (taken from m_asStep[0:])
m_cTdiscard no of observations to discard after generation
m_cTest no of observations in estimation sample
m_cU_RM max no of X and U variables (at lag 0) in reference model
m_cXlag_RM lag-length of X's in reference model
m_cX_RM max no of X and U variables (at lag 0) in reference model
m_cYlag_RM max Y lag in reference model
m_dARParDGP optional autoregressive error
m_dSigmaDGP DGP uses N[0,sigma^2]
m_dXcorrelation settings for X correlation
m_iConstant_RM specifies constant in reference model, one of USE_CONSTANT_...
m_iDGP DGP number (if any)
m_iPeriod1est sample to use in estimation
m_iPeriod2est sample to use in estimation
m_iUvar the regressor type identifiers
m_iXcorrelationMode settings for X correlation
m_iXvar the regressor type identifiers
m_iYear1est sample to use in estimation
m_iYear2est sample to use in estimation
m_iYvar the regressor type identifiers
m_oRefModel the client Modelbase object
m_sTitle title (string)
m_vParDGP_RM DGP coefficients of the reference model (0: excluded)
m_vParModelNonZero_RM model formulation in terms of the reference model

SimDesign Functions details

SimDesign

SimDesign :: SimDesign ( const obj , const iYvar , const iXvar , const iUvar )
Constructor: sets client object and variable type identifiers. SimDesign takes a Modelbase-derived object to formulate the reference model into. The DGP and model are then (sub)sets of this reference model. SimDesign then creates data into a clone of the reference model.
Parameters:
obj reference to Modelbase derived client object. NB SimDesign takes ownership of this object, and will delete it when the destructor is called.
iYvar identifies endogenous variables
iXvar identifies free regressors
iUvar identifies unrerstricted (fixed) regressors

~SimDesign

SimDesign :: SimDesign ( )
Destructor.

AddExtrasToReference

virtual SimDesign :: AddExtrasToReference ( )
Override this virtual function to add additional terms to the reference model
Returns:
array with added names ({} for none)

AddImpulseBreakToRefPar

SimDesign :: AddImpulseBreakToRefPar ( vPar , const dFraction , const dSize , const bUseSteps )
Adds a break to a parameter vector formulated in terms of impulse dummies that are in the client database. This should be called after CreateReference.
Parameters:
vRefPar reference parameter vector to add break to
dFraction >=2 break of size dSize in every dFraction'th observation >=0 break of size dSize in first round(dFraction * m_cTest) observations >=-1 break of size dSize in last round(-dFraction * m_cTest) observations >=-100 break of size dSize in 5 blocks of round(-dFraction/100 * m_cTest / 5) obs evenly spread as: [bbbb .... bbbb .... bbbb .... bbbb .... bbbb]
dSize scalar specifying size for each break (== 0: do nothing), or vector of break sizes (one entry for each break, first entry is for first break value, etc.).
Returns:
vRefPar modified for break

CreateDatabase

virtual SimDesign :: CreateDatabase ( const sFile , const cTmax , const cXmax , const vSteps )
Creates database for the DGP in the client object
Parameters:
sFile if string: file to load
cTmax no of observations in the created database
cXmax no of regressors k in the created database
vSteps empty or Sx2 matrix with step indices. This creates i=0,..,S-1 steps, wich are one for observations vSteps[i][0] : vSteps[i][1], and zero otherwise.

First the database is created (from file or empty) with cTmax observations. Deterministic(2) is called to add Constant, Trend and Seasonal. Then y, Dy and u are appended, followed by x1,..,xk. Finally, if vSteps is not <> then it specifies the step dummies to add to the DGP, with names Step[#:#] where # is the observation index.

Remember that an Ox program starts with the default seed. I normally use the convention to run each experiment of the default seed (so related experiments use the same data). However, this could cause problems if random data is created here, because it can be identical to that in the first replication.


CreateReference

virtual SimDesign :: CreateReference ( const cYlag , const cX , const cXlag , const iConstantMode , const bTrend , const cStep , const cTdiscard , const cTest )
Creates the design, which is the reference model for the DGP and GUM
Parameters:
cYlag no of lags for dependent variable
cX no of regressors
cXlag lag length for regressors
iConstantMode treatment of Constant: USE_CONSTANT_NONE, USE_CONSTANT_U, USE_CONSTANT_X
bTrend TRUE for a Trend in the GUM
cStep number of steps in the GUM: added to the database by CreateDatabase, and selected in that order.
cTdiscard no of observations to discard. The actual number discarded is max(cTdiscard,cYlag,cXlag).
cTest no of observations to use for estimation

Calls FormulateReferenceModel to formulate the reference model in the client object. Calls SetModel to make the model the same as the reference model (this can be changed later).


DummySaturation

virtual SimDesign :: DummySaturation ( const sType , const cTdiscard )
Saturates the client database with the specified dummies. This should be called after CreateDatabase and before CreateReference.
Parameters:
sType type: "I:", "DI:", "S1:", "S".
cTdiscard no of leading dummy terms to discard.

FormulateDGP

SimDesign :: FormulateDGP ( const oClient )
Formulates the DGP model in the client object.
Parameters:
oClient the client object.

FormulateModel

SimDesign :: FormulateModel ( const oClient )
Formulates the model in the client object.
Parameters:
oClient the client object.

FormulateModelInReference

SimDesign :: FormulateModelInReference ( const oClient , const vParInGUM , const iConstantMode , const bUseDeltaY )
Formulates a model in the client object with respect to the reference model.
Parameters:
oClient target client object
vParInRef parameter values, non-zero selects the corresponding term
iConstantMode mode for the Constant (if included)
bUseDeltaY if TRUE, the model is formulated with Dy instead of y The order of variables is: 1) y or Dy 1) Constant (if any: Xvar or Uvar) 2) Trend (if any) as Xvar 2) lags of y: y_1,..,y_p as Yvar 3) X regressors: x1,..x1_r, x2,..x2_r, ... 4) Step breaks created in CreateDatabase as Xvar 5) Dummies as Xvar 6) AddExtrasToReference So the constant is always the last term.

FormulateReferenceModel

virtual SimDesign :: FormulateReferenceModel ( const oClient )
Formulates the reference model in the client object.
Parameters:
oClient target client object
Returns:
array with parameter names The order of variables is: 1) y 2) lags of y: y_1,..,y_p as Yvar 3) X regressors: x1,..x1_r, x2,..x2_r, ... 4) Step breaks created in CreateDatabase as Xvar 5) Dummies as Xvar 6) AddExtrasToReference 7) Trend (if any) as Xvar 8) Constant (none, Xvar or Uvar) So the constant is always the last term.

Generate

virtual SimDesign :: Generate ( const oClient , const iRep )
Generates X, u, y, Dy, stores them in the client database.
Parameters:
oClient the object to generate data into. This should be a clone of the reference object (so that the reference model is already formulated).
iRep replication index (0 is first)

GenerateX

virtual SimDesign :: GenerateX ( const iRep , const cT )
Generates X.
Parameters:
iRep replication index (0 is first)
cT sample size
Returns:
generated X

GetARParInDGP

SimDesign :: GetARParInDGP ( )
Returns:
residual autoregressive coefficient of the DGP (default is 0)

GetDGPno

SimDesign :: GetDGPno ( )
Gets the DGP number.

GetDgpParCount

SimDesign :: GetDgpParCount ( )
Returns:
no of parameters in the DGP

GetObsCount

SimDesign :: GetObsCount ( )
Returns:
no of observations for estimation

GetObsInitCount

SimDesign :: GetObsInitCount ( )
Returns:
no of observations that are discarded

GetRefConstantLabel

SimDesign :: GetRefConstantLabel ( )
Returns:
the label of the constant mode

GetRefModelObject

SimDesign :: GetRefModelObject ( )
Gets the client object reference

GetRefParDGP

SimDesign :: GetRefParDGP ( )
Returns:
the DGP parameters in terms of the reference model

GetRefParNames

SimDesign :: GetRefParNames ( )
Returns:
the names of the parameters in the reference model

GetRefUParCount

SimDesign :: GetRefUParCount ( )
Returns:
no of U variables in the reference model

GetSigmaInDGP

SimDesign :: GetSigmaInDGP ( )
Returns:
residual standard deviation of the DGP (default is 1)

GetTitle

SimDesign :: GetTitle ( )
Gets the title

IsModelDeltaY

SimDesign :: IsModelDeltaY ( )
Returns TRUE if using Dy as dependent variable in FormulateModel, FALSE otherwise (default).

PreGenerate

virtual SimDesign :: PreGenerate ( const oClient )
To be called after setting the initial seed (optional) for the experiment, but before starting the Monte Carlo loop.

RemoveFromModel

SimDesign :: RemoveFromModel ( const asPar )
Removes variables by name from the model.
Parameters:
asPar array of names to remove (give zero parameter in reference model).

SetDGP

SimDesign :: SetDGP ( const vPar )
Sets the DGP parameters in terms of the reference model.
Parameters:
vPar parameters for the DGP, corresponding to the order in the reference model.

SetDGPError

SimDesign :: SetDGPError ( const dESE , const dARPar )
Sets the DGP error properties.
Parameters:
dESE standard error (default 1)
dARPar autoregressive parameter (default 0)

SetDGPno

SimDesign :: SetDGPno ( const iDGP )
Sets the DGP number. This can be used by derived class to denote variations of the DGP.

SetModel

SimDesign :: SetModel ( const vPar )
Sets the DGP parameters in terms of the reference model.
Parameters:
vPar parameters for the DGP, corresponding to the order in the reference model. A non-zero value indicates that the variable is in the model.

SetRenewX

SimDesign :: SetRenewX ( const bRenewX )
Set TRUE if data on X is to be renewed for every replication, FALSE otherwise.

SetTitle

SimDesign :: SetTitle ( const sTitle )
Sets the title

SetXAutoCorrelation

SimDesign :: SetXAutoCorrelation ( const dXautocorr )

SetXCorrelation

SimDesign :: SetXCorrelation ( const dCorrelation , const iMode )
Creates a correlation matrix for X by setting rho.
Parameters:
dCorrelation rho
bConstant USE_XCOR_MATCONST: one on diagonal, rho otherwise; USE_XCOR_MATPOWIJ: rho^|i-j|; USE_XCOR_AUTO: autocorrelated regressors, scaled by sqrt(1 - rho^2) NB With USE_XCOR_AUTO the first observation will be zero. Ideaaly this is taken into account by incrementing no of discards when calling CreateReference.

TransformX1

virtual SimDesign :: TransformX1 ( const mX )
X transformation immediately after drawing the N[0,1] terms.
Parameters:
mX generated X
Returns:
transformed X (default is same as input X)

TransformX2

virtual SimDesign :: TransformX2 ( const mX )
X transformation after applying correlation (if any) to X.
Parameters:
mX correlated X
Returns:
transformed X (default is same as input X)

UndoFormulateModelDeltaY

SimDesign :: UndoFormulateModelDeltaY ( const oClient )
Reformulates the model in the client object from Dy to y, and re-estimates.
Parameters:
oClient the client object.

UseModelDeltaY

SimDesign :: UseModelDeltaY ( const bUseDiff )
Set TRUE to use Dy as dependent variable in FormulateModel, FALSE otherwise.

SimDesign Data details

m_asDummy

decl m_asDummy [protected]
names of dummy saturation terms added to the database

m_asEps

decl m_asEps [protected]
names of y, residual and regressors X created in m_oRefModel

m_asPar_RM

decl m_asPar_RM [protected]
names of the regressors of the reference model

m_asStep

decl m_asStep [protected]
optional step dummies added by Create(), with names Step[#:#]

m_asX

decl m_asX [protected]
names of y, residual and regressors X created in m_oRefModel

m_asY

decl m_asY [protected]
names of y, residual and regressors X created in m_oRefModel

m_bHaveX

decl m_bHaveX [protected]
TRUE if m_oRefModel has data on X

m_bModelDeltaY

decl m_bModelDeltaY [protected]
TRUE: using Dy as dependent variable in FormulateModel

m_bRenewX

decl m_bRenewX [protected]
TRUE if data on X is to be renewed for every replication

m_bTrend_RM

decl m_bTrend_RM [protected]
TRUE: Trend in GUM

m_cStep_RM

decl m_cStep_RM [protected]
no of step dummies in reference model (taken from m_asStep[0:])

m_cTdiscard

decl m_cTdiscard [protected]
no of observations to discard after generation

m_cTest

decl m_cTest [protected]
no of observations in estimation sample

m_cU_RM

decl m_cU_RM [protected]
max no of X and U variables (at lag 0) in reference model

m_cXlag_RM

decl m_cXlag_RM [protected]
lag-length of X's in reference model

m_cX_RM

decl m_cX_RM [protected]
max no of X and U variables (at lag 0) in reference model

m_cYlag_RM

decl m_cYlag_RM [protected]
max Y lag in reference model

m_dARParDGP

decl m_dARParDGP [protected]
optional autoregressive error

m_dSigmaDGP

decl m_dSigmaDGP [protected]
DGP uses N[0,sigma^2]

m_dXcorrelation

decl m_dXcorrelation [protected]
settings for X correlation

m_iConstant_RM

decl m_iConstant_RM [protected]
specifies constant in reference model, one of USE_CONSTANT_...

m_iDGP

decl m_iDGP [protected]
DGP number (if any)

m_iPeriod1est

decl m_iPeriod1est [protected]
sample to use in estimation

m_iPeriod2est

decl m_iPeriod2est [protected]
sample to use in estimation

m_iUvar

decl m_iUvar [protected]
the regressor type identifiers

m_iXcorrelationMode

decl m_iXcorrelationMode [protected]
settings for X correlation

m_iXvar

decl m_iXvar [protected]
the regressor type identifiers

m_iYear1est

decl m_iYear1est [protected]
sample to use in estimation

m_iYear2est

decl m_iYear2est [protected]
sample to use in estimation

m_iYvar

decl m_iYvar [protected]
the regressor type identifiers

m_oRefModel

decl m_oRefModel [protected]
the client Modelbase object

m_sTitle

decl m_sTitle [protected]
title (string)

m_vParDGP_RM

decl m_vParDGP_RM [protected]
DGP coefficients of the reference model (0: excluded)

m_vParModelNonZero_RM

decl m_vParModelNonZero_RM [protected]
model formulation in terms of the reference model

SimDesign Enums details

enum1

enum { USE_CONSTANT_NONE, USE_CONSTANT_U, USE_CONSTANT_X } [public]

enum2

enum { USE_XCOR_MATCONST, USE_XCOR_MATPOWIJ, USE_XCOR_AUTO } [public]

enum3

enum { SAT_NONE, SAT_IIS, SAT_SIS, SAT_IIS_SIS } [public]