CMOMENT Instruction |
CMOMENT( options ) start end
# list of variables (in Regression Format)
# second list of variables (only if using ZMATRIX option)
Forms the cross-moment matrix \({\bf{X'X}}\) of a set of series. With the CORR option, it computes their correlation matrix.
Parameters
start, end |
range over which matrix is computed. This defaults to the maximum range allowed by the variables. |
Supplementary Cards
The first supplementary card lists the variables to include in the cross-moment matrix. You must include in this list the dependent variable(s) of any regressions that you plan to base on this CMOMENT. Omit this if using the EQUATION, LASTREG, MODEL, or INSTRUMENTS option.
The second card is used only with ZXMATRIX.
Description
Cross-moment and correlation matrices themselves are important in statistical work. However, the main uses of CMOMENT come from the fact that a cross moment matrix which includes both the explanatory variables and the dependent variable(s) of a linear regression have all the sample information required to compute regression coefficients and sums of squared residuals. This can be used in several ways within RATS:
•The LINREG instruction with the CMOMENT option pulls that information out of the computed cross product matrix. This can cut down on the computation time required for doing large numbers of similar regressions, and also ensures that all those regressions use a common sample. See, for example, the information criterion search in AKAIKE.RPF.
•The %RANMVPOSTCMOM, %RSSCMOM (for univariate regressions) and %RANMVKRONCMOM and %SIGMACMOM (for multivariate regressions) functions simulate coefficients from the posterior in a linear model (the %RAN... functions) or compute the sum of squared residuals or covariance matrix (the other two) using the statistics included in the cross-moment matrix. This is a huge time-saver in simulations as the only calculation that depends upon the data gets computed just once, rather than with every draw.
•The %SWEEP function can be used to do a sequence of "regressions" using a common sample range if all you need are the coefficients and sum of squared residuals.
Options
PRINT/[NOPRINT]
print (display) computed matrix
SMPL=Standard SMPL option[unused]
SPREAD=residual variances series [unused]
for subsequent weighted least squares estimation
WEIGHT=series of weights for the data points
Use this option if you want to provide different weights for each observation.
SHUFFLE=SERIES[INTEGER] with entry remapping[unused]
CORR/[NOCORR]
CENTER/[NOCENTER]
With CORR, CMOMENT computes the correlation matrix instead of the cross-moment matrix. With CENTER, it computes a centered (means subtracted) cross-moment matrix. You cannot use a LINREG(CMOMENT) instruction after CMOMENT with either of these.
EQUATION=equation supplying variables [unused]
LASTREG/[NOLASTREG]
MODEL=model supplying variables [unused]
INSTRUMENTS/[NOINSTRUMENTS]
[DEPVAR]/NODEPVAR
These provide shortcuts for using standard sets of variables. MODEL takes the explanatory variables from a model with linear equations; EQUATION takes these from a single equation, and LASTREG uses the explanatory variables from the last regression (or similar instruction). INSTRUMENTS uses the current set of instruments as the list. If you include any of these options, omit the supplementary card.
RATS will form the cross-moment matrix using the explanatory variables, and will include the dependent variable(s) of the equation, regression, or model unless you use the option NODEPVAR.
Note: With LASTREG, the sample range is determined by the CMOM instruction (that is, by the default range, the start and end parameters, or the SMPL option), which may not be the same as the range used in the preceding regression. To use the same range as the regression, use the %regstart() and %regend() functions as the start and end parameters of the CMOM instruction.
ZXMATRIX=RECTANGULAR Z'X matrix [unused]
Takes two sets of supplementary cards, or some combination of LASTREG/EQUATION and INSTRUMENT options and possibly a supplementary card. It computes \({\bf{Z'X}}\) where \({{\bf{Z}}}\) is the first list of variables and \({\bf{X}}\) the second. If you use LASTREG or EQUATION, the variables supplied by that option will always be the first "list"; INSTRUMENT will be first if you use it but not LASTREG or EQUATION. If you only use one of these options, use a single supplementary card to supply the other list of variables. You cannot use a LINREG(CMOMENT)instruction after CMOMENT with the ZMATRIX option.
MATRIX=SYMMETRIC matrix [%CMOM]
Saves the computed matrix is the specified array. By default, it's saved into %CMOM.
SETUP/[NOSETUP]
set up cross-moment block, but do not compute.
Notes
Correlations computed by CMOM(CORR) may be different from pairwise correlations computed with the function %CORR or with CROSS. CMOMENT does the computations over a single set of entries appropriate for all the variables involved. This may not be the same as the entries which could be used for a single pair of the variables.
Missing Values
Any observation for which any of the series in the cross-moment matrix is missing is dropped from the sample.
Variables Defined
%CMOM |
the cross-moment matrix (SYMMETRIC). |
%MEANV |
VECTOR of means of the variables |
%NCMOM |
number of variables (INTEGER) |
%NOBS |
number of observations (INTEGER) |
%SCALEV |
VECTOR of scale factors (square roots of diagonal elements) by which variables would be divided to convert to correlations on CMOM(CORR). |
Examples
cmom
# constant m1{0 to 12} gnp
do lag=1,12
linreg(cmoment) gnp
# constant m1{0 to lag}
end do lag
computes a set of distributed lag regressions. This is similar to what you would get with LINREGs alone except the regressions are computed over a uniform sample period, because the CMOM is computed using the full 12-period lag length for M1.
cmom(corr,print)
# rate30 rate60 rate90 rate120 rate1yr rate2yr
computes and prints the correlation of six interest rate series.
cmom 1974:2 *
# uscpi{1} exrat{1} itcpi{1} uscpi exrat italcpi
compute s=%sweeptop(%cmom,3)
*
* “sweeps out” the lag values. This, in effect, runs a one lag VAR.
*
cmom
# constant shortrate{0 to 24} longrate
linreg(cmom) longrate
# constant shortrate{0 to 24}
compute beta=%beta
*
* Draw residual precision conditional on previous beta
*
compute rssplus=nu*s2+%rsscmom(%cmom,beta)
compute hu =%ranchisqr(nu+%nobs)/rssplus
*
* Draw betas given hu
*
compute beta=%ranmvpostcmom(%cmom,hu,priorh,priorb)
uses the information in %CMOM to make random draws for the regression variance (done with the help of %RSSCMOM) and coefficients (%RANMVPOSTCMOM).
Copyright © 2025 Thomas A. Doan