UNIVERSITY OF CALIFORNIA, LOS ANGELES
Department of Economics

Economics 143 (Cameron) - Applied Regression Analysis

SHAZAM code [intlab9.sha]


If you are downloading this SHAZAM code for use on your own computer, select "File", then "Save As...", and save on your own diskette (a:) or your own hard drive (c:\) using the same filename e143sh17.sha.

IMPORTANT: you must then use an editor (like TED) to delete all of the HTML code from the top and the bottom of the file, leaving only the SHAZAM code. The line which reads "* SHAZAM code (e143sh17.sha) downloaded from UCLA Econ 143 (CAMERON) WebSite" should be the first line of your edited program file. Save the edited program as intlab9.sha



* SHAZAM code downloaded from UCLA Econ 143 (CAMERON) WebSite: 
* HTML file called e143sh17.htm, and should have 
*  been downloaded as intlab9.sha

*file 6 intlab9.out

smpl 1 154
pause
read(n:int2.dat) obs p yp m1 m2 r

stat / pcor

* date might be more informative than the usual t variable:
pause
genr date=1959+(time(-1)/4)
pause

* annual inflation rate is four times quarterly inflation rate
* make sure it is expressed in percent, rather than decimal percent:
genr infl=( 4*(p-lag(p))/p )*100

* any model using infl directly or indirectly loses the first observation
sample 2 154
pause

* real interest rate is nominal rate less inflation
genr realr=r-infl

* express money stocks and gnp in real terms (1992 dollars)
* real m1
genr realm1=(m1/p)*100

* real m2
genr realm2=(m2/p)*100

* real gnp
genr realyp=(yp/p)*100

* check to make sure the numbers make sense
pause
print r infl realr
pause


* try some simple regressions first
ols realr realyp
ols realr realm2

* now try a multiple regression, checking for multicollinearity
* save the residuals

ols realr realyp realm2 / resid=e predict=fitols exactdw auxrsqr
pause

* quarterly data:  check for first- and fourth-order autoregressive errors
* also called AR(1) and AR(4) errors

genr elag=lag(e)
genr elag1=lag(e,1)
genr elag2=lag(e,2)
genr elag3=lag(e,3)
genr elag4=lag(e,4)
* adjust sample
sample 3 154
plot e elag 
pause

sample 6 154
plot e elag4
pause

ols e elag1 elag2 elag3 elag4

sample 2 154
pause

auto realr realyp realm2 / predict=fitauto rstat
pause
auto realr realyp realm2 / order=2 predict=fitauto2 rstat
pause
* since these are quarterly data, suspect AR(4) errors
auto realr realyp realm2 / order=4 predict=fitauto4 rstat
pause

* look at all the data

* look at how nominal interest, inflation, and real interest move
*plot r infl realr date / gnu line 
* plot all of the variables used in the model
*plot realr realyp realm2 date / gnu line
* check multicollinearity
*plot realyp realm2 / gnu line
*  look at the fit from an ols model
*plot fitols realr date  / gnu line
* look for patterns in ols residuals
*plot e date / gnu line
* look at the fit from an AR(1) error model
*plot fitauto realr date  / gnu line
* look at the fit from an AR(2) error model
*plot fitauto2 realr date / gnu line
* look at the fit from an AR(4) error model
*plot fitauto4 realr date / gnu line

ols realr realyp realm2 / list





COURSE OUTLINE LECTURE OUTLINES PROBLEM SETS PROBLEM SOLUTIONS
COMPUTER LABS SHAZAM EXAMPLES DATA SETS ONLINE QUIZZES

Updated: December 3, 1997
Prepared by: Trudy Ann Cameron