UNIVERSITY OF CALIFORNIA, LOS ANGELES
Department of Economics

Economics 143 (Cameron) - Applied Regression Analysis

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



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

file 6 larent.out
sample 1 26
set nowarn
read(n:larent.dat) rent sqkld bed sqbed bath sqbath pkg beach ucla
* get descriptive statistics and data covariance matrix
stat / pcor
plot beach ucla

* regress rent on everything available
*   save the relevant sums of squares and degrees of freedom to use in
*   explicit F-tests later, but do automated F-tests following the ols.
ols rent sqkld bed sqbed bath sqbath pkg beach ucla / pcov

test
test bed=0
test bath=0
end

test
test sqkld=0
test sqbed=0
test sqbath=0
end

test beach-ucla=0

confid beach ucla

gen1 urexss=$ssr
gen1 urress=$sse
gen1 urdf=$df 

* regress rent on just the square feet variables
ols rent sqkld sqbed sqbath pkg beach ucla
gen1 r1exss=$ssr

* regress rent on just the number of rooms of each type
ols rent bed bath pkg beach ucla
gen1 r2exss=$ssr

*  ---  now do some F-tests of interest explicitly ----- *
* test whether joint contribution of bed and bath is statistically significant
gen1 f1=((urexss-r1exss)/2)/(urress/urdf)
print f1
* test whether joint contribution of sqkld,sqbed and sqbath is significant
gen1 f2=((urexss-r2exss)/3)/(urress/urdf)
print f2

* try some of the set of auxiliary regressions to look for sources of
*   multicollinearity
ols sqkld bed sqbed bath sqbath pkg beach ucla
ols bed sqkld sqbed bath sqbath pkg beach ucla
ols beach sqkld bed sqbed bath sqbath pkg ucla 

* create total square feet and total distance, also to be used to test whether
*  the coefficients on each set of variables are identical within the group
genr feet=sqkld+sqbed+sqbath
genr dist=beach+ucla
* regress rent on only the two aggregated variables, without number of rooms
*   of each type
ols rent feet pkg dist
* regress rent on feet and distance with number of rooms
ols rent feet bed bath pkg dist
* regress rent on feet, bed, bath, pkg and separate distance variables
ols rent feet bed bath pkg beach ucla
gen1 r3exss=$ssr
gen1 f3=((urexss-r3exss)/2)/(urress/urdf)
print f3

*  part (h.)
plot rent ucla
ols rent ucla
ols rent ucla beach
ols rent ucla beach bed
ols rent ucla beach bed pkg

*  part (l.)
skipif(bed.ne.1)
ols rent sqkld sqbed sqbath pkg beach ucla
delete skip$
skipif(bed.ne.2)
ols rent sqkld sqbed sqbath pkg beach ucla
delete skip$
skipif(bed.ne.3)
ols rent sqkld sqbed sqbath pkg beach ucla
ols rent sqkld sqbed sqbath beach ucla

plot rent pkg
ols rent ucla
ols rent beach ucla
ols rent beach ucla bed bath pkg





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

Updated: October 14, 1997
Prepared by: Trudy Ann Cameron