*
* @RegRESET(options)
* is a regression post-processor which performs Ramsey's RESET test. Use
* this *after* running a linear regression to test the specification of
* that regression.
*
* Options:
* H =maximum power to include
* PC=number of principal components of powers 2,...,h to include [all]
* [PRINT]/NOPRINT
*
* References:
* Ramsey(1969): "Tests for specification errors in classical
* Least-Squares Regression Analysis," JRSS-B, vol 32, 350-371.
* Lee, White and Granger(1992), "Testing for Neglected Non-linearities
* in Time Series Models," J. of Econometrics, vol 56, 269-290.
*
* Revision Schedule:
* 05/2007 Written by Tom Doan, Estima
* 06/2008 Revised to rescale each power to a unit 2nd moment (rather than
* rescaling just the fitted values). This will have an effect only when
* principal components are used. Changed principal components calculation
* to include the highest power.
* 10/2008 Correct rescaling (could have problems with very large scale data)
* 10/2009 Check for embedding missing values in SSTATS instruction
*
* Variables Defined:
* %CDSTAT and %SIGNIF are the LM version of the test statistic and its
* significance level.
*
procedure regreset
option integer h 2
option switch print 1
option integer pc h-1
*
local vect[series] xhatp
local rect vhat eigvect tt
local integer startl endl xc
local series fitted
local real mom2 rssr rssu fstat chisqr
local vector eigval
*
compute startl=%regstart(),endl=%regend()
*
* Compute the fitted values of the regression
*
prj fitted startl endl
*
* Create the requested powers of the fitted values (from **2 to **h) and
* normalize them to a unit sum of squares.
*
dim xhatp(h-1)
do i=1,h-1
set xhatp(i) startl endl = fitted**(i+1)
sstats(mean,smpl=%valid(fitted)) startl endl xhatp(i)**2>>mom2
set xhatp(i) startl endl = xhatp(i)/sqrt(mom2)
end do i
*
* Compute the cross product matrix of:
* (a) the powers of the fitted values
* (c) the residuals from the original regression
* (b) the regressors from the original regressions
*
cmom startl endl
# xhatp %resids %rlfromtable(%eqntable(0))
compute vhat=%xsubmat(%sweeplist(%cmom,%seq(h+1,h+%nreg)),1,h,1,h)
*
* Adjust the cross product to use the principal components if requested.
*
if pc