RATS 10.1
RATS 10.1

Instructions /

CVMODEL Instruction

Home Page

← Previous Next →

CVMODEL( options ) sigma AFRML BFRML

CVMODEL estimates a parametric model for a covariance matrix. Its main use is in structural VAR modeling.

 

The instruction estimates the parameters in the \(\bf{A}\) and \(\bf{B}\) matrices in
 

(1) \({\bf{A}}{{\bf{u}}_t} = {\bf{B}}{{\bf{v}}_t}\,\,\,\,;\,\,\,\,E({{\bf{v}}_t}{\bf{v}'_{t}}) = {\bf{D}}\,\,\,;\,\,\,{\bf{D}}\,\,{\rm{diagonal}}\)

 

or the \(\bf{V}\) matrix in

 

(2) \(E\left( {{{\bf{u}}_t}{\bf{u}'_t}} \right) = {\bf{V}}\)

 

In most applications, only one of \(\bf{A}\) and \(\bf{B}\) is actually used. \(\bf{A}\) and \(\bf{B}\) are specified using FRML[RECT]’s, that is, formulas which evaluate to a rectangular matrix, and \(\bf{V}\) as a FRML[SYMM].

 

This is not the only type of model for the contemporaneous relationship in the VAR. For instance, short-and-long run restrictions model the relationship indirectly by the effect on impulse responses. See @ShortAndLong for a description of that alternative method.


In general, before you use CVMODEL, you need to estimate the vector autoregression itself. (CVMODEL can be used to model the structure of any covariance matrix but by far the most important use is for structural VAR's). The VAR model is created using SYSTEM and its subcommands and estimated using ESTIMATE. Before you even try to create your structural VAR, you should analyze the dynamics of the basic VAR using the simpler Cholesky factor. Structural VAR’s take the underlying lag model as given and model only the contemporaneous relationship. If there’s a problem with the lag model (for instance, explosive roots due to some type of data error), that will be much easier to see with the Cholesky factor model, since it’s fully constructive, and doesn’t depend upon non-linear estimation.


CVMODEL is a non-linear estimation procedure, and it depends upon PARMSETs. You also need to a create FRML[RECT], that is, formulas which evaluate to a RECTANGULAR matrix, to describe the \(\bf{A}\) or \(\bf{B}\) matrix (or both) which make up your model. See the steps followed in the example below.

Parameters

sigma

The SYMMETRIC covariance matrix of the residuals \(\bf{u}\).

AFRML

A FRML[RECT] which gives the \(\bf{A}\)matrix in (1). Use * if your model doesn’t need an \(\bf{A}\)matrix. We would recommend using the newer A option instead.

BFRML

A FRML[RECT] which gives the \(\bf{B}\) matrix in (1). If your model has no \(\bf{B}\)matrix, you can leave this off. We would recommend using the newer B option instead.

 

Note: we recommend using the A and B options (see below), rather than the parameters, for inputting the \(\bf{A}\) and \(\bf{B}\) values.

 

Options

Standard Non-Linear Estimation Options

 

A=A formula producing RECTANGULAR array

B=B formula producing RECTANGULAR array

You can use these options to provide formulas for the \(\bf{A}\) and/or \(\bf{B}\) matrices. If you use these, don’t use the AFRML and BFRML parameters.

 

V=formula producing SYMMETRIC array to model covariance matrix

Use this to supply a formula that models the covariance matrix itself (omit A and B when using this option).

 

FACTOR=computed factoring matrix for sigma

If the model is just identified, this should give a matrix \(\bf{F}\) such that \({\bf{FF'}}\)=sigma. If the model is overidentified, it won’t be an exact factorization.

 

PARMSET=PARMSET to use [default internal]

This option selects the parameter set to be estimated. RATS maintains a single unnamed parameter set which is the one used for estimation if you don’t provide a named set.

 

DMATRIX=[CONCENTRATED]/IDENTITY/MARGINALIZED

DFC=degrees of freedom correction [0]

PDF=prior degrees of freedom [0]

DVECTOR=(output)VECTOR of values for diagonal of D matrix

The first three select the specific form for the maximand. The DMATRIX option determines the treatment of the “D” matrix in (1), whether it’s concentrated out, set to the identity. You can use the  DVECTOR option to capture the estimated values for this. The DFC option is used when you’re maximizing the posterior density. It gives the value of \(c\) in the formulas. The PDF option sets \(\delta\), which is used for the posterior density with \(\bf{D}\) integrated out.

 

METHOD=[BFGS]/SIMPLEX/GENETIC/ANNEALING/GA/EVALUATE

ITERATIONS=iteration limit[100]

SUBITERATIONS=subiteration limit [30]

CVCRIT=convergence limit [.00001]

TRACE/[NOTRACE]

These control the non-linear optimization. METHOD chooses the algorithm. BFGS is Broyden, Fletcher, Goldfarb and Shanno and is the only method which computes standard errors. However, it is very sensitive to initial guess values, so you might need to use a PMETHOD with one of the other methods first. EVALUATE simply evaluates the function given the initial values—by default, no output is displayed.

 

ITERATIONS sets the maximum number of iterations, SUBITERS sets the maximum number of subiterations, CVCRIT the convergence criterion. TRACE prints the intermediate results.

 

PMETHOD=BFGS/SIMPLEX/GENETIC/ANNEALING/GA

PITERS=number of PMETHOD iterations to perform [none]

Use PMETHOD and PITERS if you want to use a preliminary estimation method to refine your initial parameter values before switching to one of the other estimation methods. For example, to do 20 simplex iterations before switching to BFGS, you use the options PMETHOD=SIMPLEX, PITERS=20, and METHOD=BFGS.

 

HESSIAN=initial guess for inverse Hessian (METHOD=BFGS only)

You can use this with METHOD=BFGS. Without it, CVMODEL will start with the identity matrix.
 

OBSERVATIONS=number of observations used to compute sigma

This usually isn’t needed to estimate the parameters, but is needed in order to compute standard errors and do a test for overidentifying restrictions. The default value is the number of observations in the last regression you have run.
 

[PRINT]/NOPRINT

VCV/[NOVCV]

TITLE="title for output" ["Covariance model"]

These are the same as for other estimation instructions.

 

REJECT=FRML indicating a “rejection” zone for the parameters

If the expression evaluates to a non-zero (“true”) value, the function is immediately assigned the missing value.

Variables Defined

Regression Variables (not all of these are defined for CVMODEL)

Nonlinear Estimation Variables

%CDSTAT

test statistic for overidentifying restrictions (REAL)

%FUNCVAL

the log likelihood or log posterior of the final estimates (REAL)

%SIGNIF

significance level for the overidentifying restrictions test (REAL)

%NVAR       

number of variables (INTEGER)

%NFREE

number of free parameters (including diagonal if concentrated/marginalized) (INTEGER)

Examples

This estimates a model for a six-variable covariance matrix. With nine free parameters, this is overidentified by six. (There are 21=6x(6+1)/2  distinct values in a 6x6 covariance matrix, with six parameters used for the variances of the v’s, leaving fifteen to be estimated as part of the model). It is estimated using the BFGS method. The "Sample Output" is from this example.

 

The factor matrix is put into AFACTOR. Note that AFRML must be declared as a FRML[RECT] before it can be defined using the FRML instruction.

 

nonlin rx ur cu cr pc pr mp mc mr

dec frml[rect] afrml

frml  afrml = ||1.0,0.0,ur ,0.0,0.0,0.0|$

                cu ,1.0,cr ,0.0,0.0,0.0|$

                0.0,0.0,1.0,rx ,0.0,0.0|$

                0.0,0.0,0.0,1.0,0.0,0.0|$

                0.0,mc ,mr ,0.0,1.0,mp |$

                0.0,pc ,pr ,0.0,0.0,1.0||

compute ur=cu=cr=rx=mc=mr=mp=pc=pr=0.0


 

cvmodel(method=bfgs,factor=afactor,a=afrml) %sigma


 

The code below uses the V option to estimate a one factor model for the covariance matrix RR.

 

dec vect lambda(n) d(n)

compute lambda=%const(0.1)

compute d=%xdiag(rr)

dec frml[symm] vf

frml vf = %outerxx(lambda)+%diag(d)

cvmodel(method=bfgs,v=vf,obs=tdim) rr


 

A complete example is shown at CVMODEL.RPF, which does both an A form and a B form model. Note that the shocks in a structural VAR often don't correspond directly to the variables (particularly with a "B" model), so you need to be careful about labeling them if you do impulse responses or error decompositions. For instance, the "B" model in CVMODEL.RPF labels them as two real, two financial and two nominal:


errors(model=canmodel,factor=bfactor,steps=28,window="BModel",$

   labels=||"Real 1","Real 2","Fin 1","Fin 2","Nom 1","Nom 2"||)

Sample Output

This is the output from the first example above. With METHOD=SIMPLEX or METHOD=GENETIC, the only columns that will show in the bottom table will be "Variable" and "Coeff", since neither of those methods can compute standard errors.

 

If the model is overidentified (this one is), it will show both the Log Likelihood of the estimated model, and the unrestricted Log Likelihood, along with the test of the restrictions. For a just identified model, it will show both the likelihoods, but no test. The two likelihoods should match­—if they don’t, you hit a local but not global maximum.

 

Covariance Model-Concentrated Likelihood - Estimation by BFGS

Convergence in    18 Iterations. Final criterion was  0.0000036 <=  0.0000100


 

Observations                              100

Log Likelihood                      -581.0251

Log Likelihood Unrestricted         -578.6729

Chi-Squared(6)                         4.7044

Significance Level                  0.5822397


 

    Variable                        Coeff      Std Error      T-Stat      Signif

************************************************************************************

1.  RX                            0.096444107  0.036448472      2.64604  0.00814402

2.  UR                           -0.099392031  0.072928665     -1.36287  0.17292460

3.  CU                           -0.504940777  0.101094034     -4.99476  0.00000059

4.  CR                            0.146654493  0.070767740      2.07234  0.03823417

5.  PC                           -0.226894566  0.224566786     -1.01037  0.31232014

6.  PR                            0.306165767  0.168009982      1.82231  0.06840842

7.  MP                           -0.121270299  0.047061900     -2.57683  0.00997123

8.  MC                            0.204902929  0.097857582      2.09389  0.03626986

9.  MR                            0.040662281  0.075938429      0.53546  0.59232917

Common Problems

The most common problem to start is poor preparation of the underlying VAR. As mentioned above, you should always do a basic VAR analysis to make sure that the implied dynamics of the model are acceptable. If you run the VAR over a range which includes "flat spots" in the some of the variables (due to currency or price controls, for instance), it will be hard to come up with a sensible SVAR—an endogenous variable in a VAR should not behave that way. If the data have at least reasonable dynamic behavior, another common error is incorrect choice of transformation. Most economic data are typically put into a VAR in log form (log GDP, log prices, log money stock). Interest and unemployment rates are common exceptions to that. Data series such as trade or budget deficits which can't be done in logs because of sign issues should either be separated into their two components (for instance, revenues and expenditures) and done in logs or deflated by (for instance) GDP.


If you are creating a new SVAR (not one already proposed in the literature), note that it becomes increasingly difficult to set up a workable model as the number of variables increases. Despite the apparent similarity to simultaneous equations models, these are in fact quite different. If your model is strongly rejected by the likelihood ratio test, you need to either fix the structural model or go back and change the underlying VAR. The FACTOR option produces the matrix that your model says should be (close to) a factor of the covariance matrix. The likelihood ratio test is testing how far off that is from being true. You can try to isolate the cause by comparing the outer product of the factor with the original covariance matrix. If (for instance), you saved the "factor" matrix into BFACTOR, then
 

display %outerxx(bfactor) %sigma

 

will show the model's attempt (first matrix) to reproduce the covariance matrix (second matrix).

 

These models can be quite difficult to estimate successfully. There are often multiple local maxima, and there can even be multiple global maxima in very different regions of the parameter space. Before you put a lot of effort into writing up results, experiment with different initial guess values and PMETHOD=GENETIC to make sure you didn’t end up at the wrong spot on the first try.

BERNANKE.SRC (@BERNANKE procedure)

CVMODEL was added to RATS with version 5. Before that, a procedure on the file BERNANKE.SRC could be used to estimate "A" form models. Since CVMODEL is more general, runs faster and has more estimation options, the procedure was phased out. If you have some old programs that use @BERNANKE, it's generally relatively straightforward to adapt the estimation to use CVMODEL instead. The procedure used a "pattern" matrix which had 0's and 1's which marked the locations where the free parameters in the A form were. Exact 1's on the diagonal were assumed. So the model in the first example above would have been represented by the pattern input:

 

dec rect mysvar(6,6)

input mysvar

 1 0 1 0 0 0

 1 1 1 0 0 0

 0 0 1 1 0 0

 0 0 0 1 0 0

 0 1 1 0 1 1

 0 1 1 0 0 1

@bernanke %sigma mysvar factor

 

To take an older @BERNANKE procedure pattern matrix and convert it to use in CVMODEL, you need to define parameter variables for the free off-diagonal parameters. For instance, if you started with the pattern matrix above, you might instead do

 

nonlin a13 a21 a23 a34 a52 a53 a56 a62 a63

 

naming them based upon their positions. (Again, note that 1's on the diagonal are assumed, so you don't include them in the parameter set). Our preference is generally not to do that, and to use somewhat more descriptive labels (UR is Unemployment equation, Rate variable), MP is Money equation, Price variable) since that's more flexible, but either will work fine. With the position names, you could define the FRML's for use with CVMODEL as

 

dec frml[rect] myfrml

frml myfrml = ||1.0,0.0,a13,0.0,0.0,0.0|$

                a21,1.0,a23,0.0,0.0,0.0|$

                0.0,0.0,1.0,a34,0.0,0.0|$

                0.0,0.0,0.0,1.0,0.0,0.0|$

                0.0,a52,a53,0.0,1.0,a56|$

                0.0,a62,a63,0.0,0.0,1.0||

 

It's a very good idea to do follow the examples shown and align the elements in a column to make it easier to read. Spaces can be freely used within the FRML definition.


Copyright © 2025 Thomas A. Doan