Contents Index Summary Citation Doornik

Ox Class Reference

Contents:
Database class
Database function members
Database data members
PcFiml class
PcFiml function data members
PcNaiveDgp class
PcNaiveDgp function members
PcNaiveDgp data members
Sample class
Sample function members
Sample data members
Simulation class
Simulation function members
Simulation data members

Database class

The Database class stores a matrix of data, together with the sample period (the class derives from the Sample class), and the names of the variables. Functions to create a database from disk files (ASCII, GiveWin and spreadsheet formats) are provided. A sample period for selection can be set, variables are selected by name, optionally with a lag length. This selection can then be extracted from the database. The selected sample is always adjusted so as not to include missing values (-9999.99). To use the class, link in the database code and include database.h.

Database function members

Database::Append(const mNew, const asNew, const iT1);
mNew
in: T x k matrix with the new variables
asNew
in: array with k variable names of the new variables
iT1
in: starting observation index in database
Appends the k new variables to the database, storing the observations and variable names. The first observation has database index iT1 (use 0 if the variables start at the same sample point as the database), the last is the end of the database sample, or the end of mNew, whichever comes first.
Create(const iFreq, const iYear1, const iPeriod1,
    const iYear2, const iPeriod2);
iFreq
in: int, frequency
iYear1
in: int, start year
iPeriod1
in: int, start period
iYear2
in: int, end year
iPeriod2
in: int, end period
Creates a database. Use this when the database is not to be loaded from disk. The Append member function allows adding data to the database.
Database::Database();
Constructor.
Database::DeSelect();
Clears the current selection.
Database::Deterministic(const fCseason);
Appends constant, trend and seasonals to the database. These variables are named Constant, Trend and Season. Season_1, ..., Season_x, where x is the frequency. Season has a 1 in quarter 1 (for quarterly data), and zeros elsewhere, Season_1 has a 1 in quarter 2, etc. If fCseason is TRUE, the seasonals are centred (with quarterly observations, for quarter 1: 0.75, -0.25, -0.25, -0.25, ...), in which case the names are CSeason, CSeason_1, ..., CSeason_x.
Database::FindSelection(const sVar, const iLag);
sVar
in: string, variable name
iLag
in: int, lag length
Returns the selection index of the specified variable with the specified lag, or -1 if it is not selected.
Database::GetAll();
Returns the whole database matrix.
Database::GetGroup(const iGroup);
Database::GetGroupLag(const iGroup, const iLag1, const iLag2);
iGroup
in: int, group number
iLag1
in: int, first lag
iLag2
in: int, last lag
GetGroup returns a T x n matrix with all selected variables of group iGroup.

GetGroupLag returns only those with the specified lag length. If no database sample has been selected yet, the return value is a 0.

Database::GetGroupLag(const iGroup, const iLag1,
    const iLag2, aasNames);
iGroup
in: int, group number
iLag1
in: int, first lag
iLag2
in: int, last lag
aasNames
in: array
out: will hold an array of strings with the names of the variables with specified group and lag
GetGroupLag gets the names of all selected variables of group iGroup which have a lag in iLag1 ... iLag2. The selection sample period must have been set.
Database::GetMaxLag();
Database::GetMaxGroupLag(iGroup);
GetMaxLag returns the highest lag in all selected variables. GetMaxGroupLag returns the highest lag in selected variables of the specified group iGroup.
Database::GetSelStart();
Database::GetSelEnd();
GetSelStart returns the database index of the first observation of the selected sample. GetSelEnd returns the database index of the last observation of the selected sample.
Database::GetSelSample();
GetSelSample returns a string with the selected sample text, e.g. "1980 (1) - 1984 (2)".
Database::GetVar(const sName);
GetVar returns the specified variable, or 0 if the variable cannot be found.
Database::Info();
Prints information on the contents of the database.
Database::LoadDht(const sFilename, const iYear1,
    const iPeriod1, const iFreq);
Database::LoadFmtVar(const sFilename);
Database::LoadIn7(const sFilename);
Database::LoadObs(const sFilename, const cVar,const cObs,
    const iYear1, const iPeriod1, const iFreq,
    const fOffendMis);
Database::LoadVar(const sFilename, const cVar,const cObs,
    const iYear1, const iPeriod1, const iFreq,
    const fOffendMis);
Database::LoadWks(const sFilename);
Database::LoadXls(const sFilename);
sFilename
in: string, filename
cVar
in: int, number of variables
cObs
in: int, number of observations
iYear1
in: int, start year
iPeriod1
in: int, start period
iFreq
in: int, frequency
fOffendMis
in: int, TRUE:offending text treated as missing value FALSE: offending text skipped

LoadDht creates the database and loads the specified Gauss data file from disk.

LoadIn7 creates the database and loads the specified GiveWin file (which is the same as a PcGive 7 data file) from disk.

LoadFmtVar creates the database and loads the ASCII file with formatting information from disk. In GiveWin this is called `Data with load info'. Such a file is human-readable, with the data ordered by variable, and each variable preceded by a line of the type:

> name year1 period1 year2 period2 frequency

LoadObs and LoadVar create the database and load the specified human-readable data file from disk. The data is ordered by observation (LoadObs), or by variable. Since there is no information on the sample or the variable names in these files, the sample must be provided as function arguments. The variable names are set to Var1, Var2, etc., use Rename to rename the variables.

LoadWks and LoadXLS create the database and load the specified spreadsheet file from disk. A .wks or .wk1 file is a Lotus file, an .xls file is an Excel worksheet (up to version 4).

Database class can read the following types of Excel file:

  • Excel 2.1;
  • Excel 3.0;
  • Excel 4.0 (called `normal' inside Excel 4).
When saving an Excel file, it is written in Excel 2.1 format.
Database::Remove(const sName);
Removes the named variable from the database.
Database::Rename(const sNewName, const sOldName);
sNewName
in: new name
sOldName
in: name of database variable to rename
Renames a database variable.
Database::Renew(const mNew, const sName, const iT1);
mNew
in: T x 1 matrix
sName
in: variable names
iT1
in: first observation
Renews the observations on the named variable. The first new observation has database index iT1, the last is the end of the database sample, or the end of mNew, whichever comes first.
Database::SaveIn7(const sFilename);
Database::SaveFmtVar(const sFilename);
Database::SaveObs(const sFilename);
Database::SaveVar(const sFilename);
Database::SaveWks(const sFilename);
Database::SaveXls(const sFilename);
sFilename
in: string, filename

SaveIn7 saves the database as a GiveWin file.

SaveFmtVar saves the database as a formatted ASCII file. Also see under LoadFmtVar.

SaveObs and SaveVar save the database as a human-readable data file, ordered by observation, or by variable. Also see under LoadObs, LoadVar.

SaveWks and SaveXls save the database as a Lotus or Excel spreadsheet file. Also see under LoadWks, LoadXls.

Database::Select(const iGroup, const aSel);
Selects variables by name and with specified lags, and assigns the iGroup number to the selection. The aSel argument is an array consisting of sequences of three values: name, start lag, end lag. After a sample period is set, the selection can be extracted from the database.
Database::SetSample(const iYear1, const iPeriod1,
    const iYear2, const iPeriod2);
iYear1
in: int, start year of selection, use -1 for earliest year and period
iPeriod1
in: int, start period of selection
iYear2
in: int, end year of selection, use -1 for latest year and period
iPeriod2
in: int, end period of selection
Selects a sample for the variables previously selected with the Select function. The actually selected sample will be the largest starting from the specified starting date (but not exceeding the specified end date) without any missing values. Use DeSelect to deselect the current sample and variables.

Database data members

m_mData
data matrix (T x k)
m_asNames
variable names (array with k strings)
m_mVarsel
variable selection (1 x s matrix with selection) the selection consists of indices in m_mData and m_asNames
m_mLagsel
lag length of each entry in m_mVarsel (1 x s matrix)
m_mSelgroup
group number of each entry in m_mVarsel (1 x s matrix)
m_iT1sel
row index in m_mData of first selected observation (int)
m_iT2sel
row index in m_mData of last selected observation (int)

PcFiml class

The PcFiml class provides part of the advanced computations available in the menu driven computer program PcFiml. The class is derived from the Database class, and provides model formulation using variable names. The class allows for estimating a Vector Autoregression (VAR), cointegration analysis (`Johansen procedure'), and multivariate regression model (such as an unrestricted reduced form, URF), as well as a simultaneous equations model (2SLS, 3SLS, FIML). No identities equations are currently possible. Mis-specification tests include: vector autoregression, vector normality, vector heteroscedasticity, vector portmanteau, as well as a Chow test.

PcFiml function data members

ArTest(const iAr1, const iAr2);
System vector AR test for lags iAr1... iAr2.
Chow(const iYear, const iPeriod);
Forecast Chow tests for break on or after iYear (iPeriod).
Cointegration();
Estimate cointegrating space.
EgeArTest(const iAr1, const iAr2);
Model vector AR test for lags iAr1...iAr2.
Estimate();
Estimate the system (NB: use ->SetSample() first).
EstimateAcc();
SVD based estimation of the system (NB: use ->SetSample() first).
Fiml();
Do FIML estimation.
GetOmega();
Returns n x n matrix of URF/RRF residual variance V'V/(T-k).
GetPi();
Returns n x k matrix of URF/RRF coefficients.
GetResiduals();
Returns T x n matrix V of URF/RRF residuals.
GetResult();
Returns results from FIML estimation (return code from MaxBFGS).
GetVarPi();
Returns n x k matrix with variances of RRF/URF coefficients.
GetVarTheta();
System: returns full nk x nk variance-covariance matrix of URF coefficients;
Model: returns full np x np variance-covariance matrix of model coefficients.
HeteroTest(const fStand, const fCross);
Vector heteroscedasticity test.
NormalityTest();
Vector normality test.
Output(const fSys, const fCoint);
Print System and/or Cointegration results.
PcFiml();
Constructor.
Portmanteau(const iLag);
Vector portmanteau test up to lag iLag.
SetEquation(const sEquation, const aModel);
Delete or add variable from model.
SetPrint(fPrint);
Toggles print switch.
SetPrintUrf(fPrintUrf);
Toggles URF print switch.
ThreeSLS();
Do 3SLS estimation.
TwoSLS();
Do 2SLS estimation.

PcNaiveDgp class

The PcNaiveDgp class is a data generation process (DGP), designed for use in dynamic econometric Monte Carlo experiments. The class is used through the header file pcnaive.h. The design is an n-variate version DGP:
yt = A0yt + A1yt-1 + A2zt + a3 + ut,
ut = B0ut-1 + et + B1et-1,
zt = C0zt-1 + c1 + c2t + vt.
The vectors yt,ut,et are n x 1, so that the coefficient matrices A0,A1,B0,B1 are n x n, and a3 is n x 1. The zt vector is q x 1, making a2 n x q, C0 q x q, and c1,c2 q x 1. The zs can be kept fixed between experiments, or regenerated for the experiment. A distribution for et and vt can be specified.

PcNaiveDgp function members

PcNaiveDgp::Asymp();
Prints an asymptotic analysis (companion matrix with eigenvalues) of the current DGP.
PcNaiveDgp::DiscardZ();
Discards the current zt; the next call to Generate() will generate new observations on zt.
PcNaiveDgp::Generate(const cT);
Returns generated Y = (y0 ... y_T)', as a T x n matrix.
Generates cT observation of the current DGP.
PcNaiveDgp::GetU();
PcNaiveDgp::GetY();
PcNaiveDgp::GetZ();
GetU returns current U as a T x n matrix.

GetY returns current Y as a T x n matrix (as does Generate).

GetZ returns current Z as a T x q matrix.

PcNaiveDgp::PcNaiveDgp(const cY, const cZ);
cY
in: int, n, dimension of yt
cZ
in: int, q, dimension of zt
Constructor.
PcNaiveDgp::Print();
Prints the setup of the current DGP.
PcNaiveDgp::SetDistribution(const iEqn, const iDist,
    mPar1, mPar2);
iEqn
in: one of: U_DGP, Z_DGP
iDist
in: one of: NO_DIST, NORMAL, MVNORMAL, LOGNORMAL, T_DIST, F_DIST, EXPONENTIAL, MVNARCH, MVNHETERO
mPar1
in: first parameter of distribution, MVNARCH, MVNHETERO: n x n for yt, ut; q x q for zt others: n x 1 for yt, ut; q x 1 for zt
mPar2
in: second parameter of distribution, MVNORMAL, MVNARCH, MVNHETERO: n x n for yt, ut; q x q for zt others: n x 1 for yt, ut; q x 1 for zt
Specifies the distribution for the u, or z equations given above. The first argument indicates the equation, the second the distribution. The last two arguments parameterize the distribution.
PcNaiveDgp::SetFixedZ(const fSetting);
Specifies whether zt is fixed (fSetting equals TRUE) or not. Fixed zt is only generated once, until a call to DiscardZ or SetFixedZ is made.
PcNaiveDgp::SetMixing(const iEqn, const iDist,
    mPar1, mPar2, const iT1, const iT2,
    const mMixParIn, const mMixParOut);
Not yet implemented
PcNaiveDgp::SetUParameter(const mLagAr, const mLagMa);
mLagAr
in: n x n matrix B0
mLagMa
in: n x n matrix B1
Sets the parameters for the et equation.
PcNaiveDgp::SetYParameter(const mLevel, const mLag,
    const mZpar, const vConst);
mLevel
in: n x n matrix A0 must have zeros on the diagonal
mLag
in: n x n matrix A1
mZpar
in: n x q matrix A2
vConst
in: n x 1 matrix a3
Sets the parameters for the yt equation.
PcNaiveDgp::SetZParameter(const mLag, const vConst,
    const vTrend);
mLag
in: q x q matrix C0
vConst
in: q x 1 matrix c1
vTrend
in: q x 1 matrix c2
Sets the parameters for the zt equation.

PcNaiveDgp data members

m_cY
n, dimension of yt,
m_cZ
q, dimension of zt,
m_mZ
generated Z, T x q,
m_mY
generated Y, T x n,
m_mU
generated U, T x n,
m_mUlag
B0', error AR parameters, n x n,
m_mElag
B1', error MA parameters, n x n,
m_iEdist
error distribution,
m_mEdistPar1
error distribution parameter 1,
m_mEdistPar2
error distribution parameter 2,
m_iEmix
error mixing distribution,
m_mEmixPar1
mixing distribution parameters, 1 x n,
m_mEmixPar2
mixing distribution parameters, 1 x n,
m_iEmixT1
first observation over which to mix,
m_iEmixT2
last observation over which to mix,
m_mEmixParIn
error mixing parameter inside sample, 1 x n,
m_mEmixParOut
error mixing parameter outside sample, 1 x n,
m_mZlag
C0', coefficients on zt-1, q x q,
m_mZconst
c1', coefficients on constant, 1 x q,
m_mZtrend
c2', coefficients on trend, 1 x q,
m_iZdist
z distribution,
m_mZdistPar1
z distribution parameters 1,
m_mZdistPar2
z distribution parameter 2,
m_iZmix
z mixing distribution,
m_mZmixPar1
z mixing distribution parameters, 1 x q,
m_mZmixPar2
z mixing distribution parameters, 1 x q,
m_iZmixT1
first observation over which to mix z ,
m_iZmixT2
last observation over which to mix z ,
m_mZmixParIn
z mixing parameter inside sample, 1 x n,
m_mZmixParOut
z mixing parameter outside sample, 1 x n,
m_fFixedZ
TRUE for fixed zt,
m_mYlevel
A0 structural coefficients on yt, n x n,
m_mYlag
A1 structural coefficients on yt-1, n x n,
m_mYparZ
A2 structural coefficients on zt, n x q,
m_mYconst
a3 structural coefficients on constant, n x 1,
m_mY0inv
D-1, D= (I-A0)',
m_mYlagRf
A1'D-1 reduced form coefficients on yt-1,
m_mYparZRf
A2'D-1 reduced form coefficients on zt,
m_mYconstRf
a3'D-1 reduced form coefficients on constant.

Sample class

The Sample class stores a time interval, and the frequency, e.g. 1980 (1) -- 1990 (1), with frequency 4 (i.e. quarterly observations). The Sample class is only used to derive from. It requires linking in the database code, and inclusion of database.h.

Sample function members

Sample::GetYear1();
The year of the first observation.
Sample::GetPeriod1();
The period of the first observation.
Sample::GetYear2();
The year of the last observation.
Sample::GetPeriod2();
The period of the last observation.
Sample::GetSize();
The number of observations in the sample.
Sample::GetIndex(const iYear, const iPeriod);
The index of the specified time point.
Sample::ObsYear(iObs);
The year of the observation index.
Sample::ObsPeriod(iObs);
The period of the observation index.

Sample data members

m_iFreq
data frequency (int)
m_iYear1
year of first observation (int)
m_iPeriod1
period of first observation (int)
m_iYear2
year of last observation (int)
m_iPeriod2
period of last observation (int)

Simulation class

The Simulation class can be used to set up Monte Carlo experiments. Derive your own simulation experimentation class from this, overriding the virtual functions. Simulation will handle the replications and storage, and print the final results. The type of data it can handle are coefficients, test statistics and p-values of test statistics. The class is used through the header file simula.h.

A table is printed at the end, which gives the results, for coefficients:

where M is the number of replications and rmse is the root of the mean squared error.

Simulation function members

virtual Simulation::Generate(const iRep, const cT,
    const mxT);
iRep
in: int, index of current replication (0 is first)
cT
in: int, sample size to be used for replication
mxT
in: int, maximum sample size to be used for replication (this is only relevant when using common random numbers)
The functions should return 1 if successful, 0 if the replications failed.

If the call to the Generate function fails, it is retried until a successful return (so always returning 0, or not returning a value could result in an infinite loop). The number of rejected replications is reported in the output.

The derived class must override the virtual function. It is called for every replication, and must perform the actual replication. The results from this replication are obtained by the simula class by calling GetCoefficients, GetPvalues and GetTestStatistics.

virtual Simulation::GetCoefficients();
virtual Simulation::GetPvalues();
virtual Simulation::GetTestStatistics();
The functions return 0 if the information is not generated, otherwise:

GetCoefficients
sc x 1 matrix with the observed coefficients GetPvalues
sp x 1 matrix with observed p-values of the tests GetTestStatistics
st x 1 matrix with the observed test statistics

Virtual functions which the derived class must override.

Simulation::SetCoefNames(const asNames)
Simulation::SetTestNames(const asNames)
asNames
in: array with names. For SetCoefNames: array with sc names; for SetTestNames: array with st names.
Installs the names of tests statistics and coefficients, to make the report more readable.
Simulation::Simulate()
This is the core function. It runs the Monte Carlo experiment, and prints the results.
Simulation::Simulation(const mT, const mxT,
    const cRep, const fCommon, const dSeed,
    const mPvalue, const mTrueParam);
mT
in: 1 x r matrix of sample sizes
mxT
in: int, maximum sample size
cRep
in: int, number of replications
fCommon
in: 1: reset seed for each experiment; else 0
dSeed
in: double, resets seed to dSeed if fCommon == TRUE
mPvalue
in: 1 x sp matrix with p-values to test at, only used if GetPvalues returns p-values
mTrueParam
in: 1 x sc matrix with true parameters, only used if GetCoefficients returns coefficients
Constructor function.

Simulation data members

m_mT
sample size matrix
m_mxT
maximum sample size
m_cRep
number of replications
m_cRejected
number of replications rejected
m_mPvalue
row vector with p-values for tests
m_asPvalue
array with names of p-values
m_asTest
array with names of tests
m_asCoef
array with names of coefficients
m_mTrueParam
actual parameter values for coeffs
m_fCommon
TRUE if same seed for each experiment
m_dSeed
reset to dSeed if fCommon==TRUE
m_mCoefMean
mean of coefficients
m_mCoefMeanSq
mean of squares of coefficients
m_mReject
rejection frequencies
m_mTestVal
sorted test values for last sample size
m_mCritVal
critical values corresponding to mPvalue


Ox version 1.10. This file last changed 18-Jul-1996.