UNIVERSITY OF CALIFORNIA, LOS ANGELES
Department of Economics

Economics 143 (Cameron) - Applied Regression Analysis

SHAZAM code [lifecyc.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 e143sh24.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 (e143sh24.sha) downloaded from UCLA Econ 143 (CAMERON) WebSite" should be the first line of your edited program file. Save the edited program as lifecyc.sha



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

file 6 lifecyc.out
* example to illustrate quadratic functions in multiple regression

sample 1 10
read(n:lifecyc.dat) y x
genr x2=x*x

* we will call y income and x age (life-cycle earnings)
plot y x 

* when we study serial correlation, we will use the first form of ols
*ols y x / noanova exactdw resid=e
ols y x 

* look at the relationship between x-squared and x:
plot x2 x 

* when we study serial correlation, we will use the first form of ols
*ols y x x2 / predict=yhat noanova exactdw resid=e
ols y x x2 / predict=yhat coef=b

plot yhat x 

* solve for the value of x that maximizes y:
gen1 x_ymax=-b:1/(2*b:2)
* plug this value of x into the equation for y to get largest fitted y:
gen1 y_ymax=b:1*x_ymax + b:2*x_ymax*x_ymax + b:3
print x_ymax y_ymax

stop




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

Updated: February 17, 1998
Prepared by: Trudy Ann Cameron