Updated July 2008 with improved handling of the principal components.
- Code: Select all
*
* @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.
*
* 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) startl endl xhatp(i)**2>>mom2
set xhatp(i) startl endl = xhatp(i)/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<h-1 {
eigen %xsubmat(vhat,1,h-1,1,h-1) eigval eigvect
compute tt=%xsubmat(eigvect,1,h-1,1,pc)~\1.0
compute vhat=%mqform(vhat,tt)
compute xc=pc
}
else {
compute xc=h-1
}
*
compute rssr=vhat(xc+1,xc+1)
compute vhat=%sweeptop(vhat,xc)
compute rssu=vhat(xc+1,xc+1)
compute fstat=(rssr-rssu)*(%ndf-xc)/(xc*rssu)
compute chisqr=%nobs*(1.0-rssu/rssr)
*
if print {
disp "RESET("+h+") Test"
if pc<h-1
disp "Using "+pc+" principal components"
disp "F("+xc+","+(%ndf-xc)+")=" @13 #####.### fstat @25 "Significance Level" #.####### %ftest(fstat,xc,%ndf-xc)
disp "LM("+xc+")=" @13 #####.### chisqr @25 "Significance Level" #.####### %chisqr(chisqr,xc)
}
*
compute %cdstat=chisqr,%signif=%chisqr(%cdstat,xc)
end
Example. This does a cubic, a fourth order and a fourth order using only one principal component of the 2nd through 4th powers.
- Code: Select all
*
* The @RegRESET(h=power) procedure is applied immediately after the regression
* that you want to test.
*
linreg lwage
# constant exper tenure married south urban black educ
@RegRESET(h=3)
@RegRESET(h=4)
@RegRESET(h=4,pc=1)
