UNIVERSITY OF CALIFORNIA, LOS ANGELES
Department of Economics

Economics 143 (Cameron) - Applied Regression Analysis

SHAZAM code [lifecyc.sha]



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

* example to illustrate quadratic functions in multiple regression

sample 1 10
read(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




Updated: 4:41 PM 11/9/98; Prepared by: Trudy Ann Cameron; Site Index