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 e143sh26.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 (e143sh26.sha) downloaded from UCLA Econ 143 (CAMERON) WebSite" should be the first line of your edited program file. Save the edited program as wls_sim.sha
* SHAZAM code downloaded from UCLA Econ 143 (CAMERON) WebSite: * HTML file called e143sh26.htm, and should have * been downloaded as wls_sim.sha file 6 wls_sim.out set nocolor * We will each create our own sample from a known "population" * with a known "population regression function," (PRF). By construction, * these data are heteroscedastic. The true population error variance * is approximately proportional to the squared value of the * explanatory variable. popsize:300 sample 1 [popsize] * CREATE SOME "POPULATION" DATA: * Let non-profit organization revenues (r) be distributed uniformly between * $500,000 and $1,500,000. genr r=500+uni(1000) * Let fund-raising expenditures or "development" costs (d) be given by * a known "data-generating process" plus an error u that depends on revenue. * The standard deviation of the PRF regression error is "sig" times r. * Thus, E[u-squared] is proportional to r-squared. sig:.05 genr u=[sig]*r*nor(1) genr d=5 + 0.2*r + u plot d r ols d r / resid=e genr e2=e*e plot e2 r genr r2=r*r * * For your particular data set (everyone's will be different), is * the squared regression error more closely associated with r * or with r2? Which would you expect, given the way the data * were constructed? ols e2 r ols e2 r2 * * Assume that the regression ols e2 r2 has the highest R-squared value. * Note that we expect it to, since that was the way the data set was * generated. It is possible that, for your particular sample, this true * underlying relationship will not be clear from the sample you have drawn. * * If your data do not reveal the true underlying form of * the heteroscedasticity in the PRF, you have learned that even our best * efforts with a sample of data will sometimes not reveal the TRUE form * of heteroscedasticity afflicting our data. Here, we know the true form, * but in any real-life application, we will not. * * Now, multiply both sides of the population regression function by 1/r. * This means that d becomes (d/r), the constant term becomes (1/r), and * the r term becomes (r/r)=1 (the new constant). * The next question is: If we do a regression of the transformed * dependent variable on the transformed explanatory * variables (where the "variable" is now 1/r), what do we get? * First, generate the transformed variables: * td= transformed d * tconst= transformed constant term * tr= transformed r, now just a constant equal to 1 * We will use OLS td tconst tr / noconstant to prevent an automatic constant genr td=d/r genr tconst=1/r genr tr=1 * * First plot transformed (td) against transformed constant (tconst) * Does this more closely satisfy the maintained hypotheses for OLS? plot td tconst * Next, run the regression through these points and NOTE the point estimates ols td tr tconst / noconstant * * Now create the appropriate weighting variable and see if you get the same * results as by explicit transformation of all variables and weighted * least squares genr wt=1/(r*r) ols d r / weight=wt stop
| COURSE OUTLINE | LECTURE OUTLINES | PROBLEM SETS | PROBLEM SOLUTIONS | COMPUTER LABS |
| SHAZAM EXAMPLES | DATA SETS | ONLINE QUIZZES | GRAPHICS | HANDOUTS |