RATS 11.1
RATS 11.1

GIV.RPF is an example of generalized instrumental variables (GMM).

 

This example runs through the calculations for the single return models in Hansen and Singleton (1982) on a constructed data set. It estimates the free parameters (the discount rate \(\beta\) and coefficient of risk aversion \(\sigma\) where the first-order condition for allocation of consumption across time yields the condition:

 

\(E_{t - 1} \left[ {\beta R_t \left( {C_t /C_{t - 1} } \right)^\sigma   - 1} \right] = 0\)

 

Theoretically, anything that’s part of the information set at time \(t-1\) can be used as an instrument. The following uses the CONSTANT (which will almost always be an instrument) and six lags of the two data series and uses the OPTIMALWEIGHTS calculation with no lags in. (You wouldn’t expect serial correlation in the moment conditions for this model.)

 

nonlin discount riskaver

frml h = discount*realret(t)*consgrow(t)^riskaver-1

compute discount = .99,riskaver = -.95

*

instruments constant consgrow{1 to 6} realret{1 to 6}

nlls(inst,frml=h,optimal) *


If you wish to provide your own weighting matrix, you can use the WMATRIX option on LINREG or NLLS. These steps would be used to compute your own weight matrix:

1.Estimate the model in the standard way, saving the residuals.

2.Use MCOV to compute the mcov(Z,u) matrix. To get the proper scale for the covariance matrix, the weight matrix needs to be the inverse of a matrix which is \(O(T)\).

3.Re-estimate the model with the option WMATRIX=new weighting matrix (if you’ve computed the inverse) or IWMATRIX=mcov matrix (matrix before inversion). If this is an (intentionally) sub-optimal weight matrix, you can use ROBUSTERRORS, LAGS and LWINDOW to correct the covariance matrix.

 

compute start=%regstart()

dofor nlag = 1 2 4 6

  instruments constant consgrow{1 to nlag} realret{1 to nlag}

  nlls(inst,noprint,frml=h,optimal) * start *

  cdf(title="Specification Test for "+nlag+" lags") $

     chisqr %jstat 2*nlag-1

end dofor


 

Full Program


calendar(q) 1960:1
open data hsdata.wks
*
data(format=wks,org=cols) 1960:1 1987:4 c price div
*
set consgrow = c/c{1}
set realret  = (price+div)/price{1}
*
nonlin discount riskaver
frml h = discount*realret(t)*consgrow(t)^riskaver-1
compute discount = .99,riskaver = -.95
*
* Estimate the model with six lags in the information set
*
instruments constant consgrow{1 to 6} realret{1 to 6}
nlls(inst,frml=h,optimal) *
*
* Do specification tests on lag lengths 1, 2, 4 and 6. These are done
* over a common interval (the range supported by the six lag estimation
* - %regstart() returns the start entry from the last regression). The
* NLLS output is suppressed and the tests results are displayed using
* cdf.
*
compute start=%regstart()
dofor nlag = 1 2 4 6
  instruments constant consgrow{1 to nlag} realret{1 to nlag}
  nlls(inst,noprint,frml=h,optimal) * start *
  cdf(title="Specification Test for "+nlag+" lags") $
     chisqr %jstat 2*nlag-1
end dofor
*
* Same specification tests using REPORT to pretty up the output
*
report(action=define,hlabel=||"Lags","J-Stat","P-Value"||)
dofor nlag = 1 2 4 6
  instruments constant consgrow{1 to nlag} realret{1 to nlag}
  nlls(inst,noprint,frml=h,optimal) * start *
  report(atcol=1,row=new) nlag %jstat %jsignif
end dofor
report(action=format,atcol=2,width=8)
report(action=format,atcol=3,picture="#.###")
report(action=show)
 

Output

GMM-Continuously Updated Weight Matrix - Estimation by Gauss-Newton

Convergence in     5 Iterations. Final criterion was  0.0000027 <=  0.0000100

Quarterly Data From 1961:04 To 1987:04

Usable Observations                       105

Degrees of Freedom                        103

J-Specification(11)                   11.4664

Significance Level of J             0.4050542

 

    Variable                        Coeff      Std Error      T-Stat      Signif

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

1.  DISCOUNT                      1.005776264  0.008623554    116.63129  0.00000000

2.  RISKAVER                     -3.413343414  1.221385603     -2.79465  0.00519562


 

Specification Test for 1 lags

Chi-Squared(1)=      3.548443 with Significance Level 0.05960134

 

Specification Test for 2 lags

Chi-Squared(3)=      4.025026 with Significance Level 0.25877443

 

Specification Test for 4 lags

Chi-Squared(7)=      7.899342 with Significance Level 0.34155357

 

Specification Test for 6 lags

Chi-Squared(11)=     11.466453 with Significance Level 0.40505211

 

Lags  J-Stat  P-Value

   1  3.54844    0.060

   2  4.02503    0.259

   4  7.89934    0.342

   6 11.46645    0.405


Copyright © 2026 Thomas A. Doan