For this exercise, you will write your do-file from scratch. Don't forget the Help option if you don't know how to do something. Make sure your do-file is well organized and well annotated.
Note: At the end of this document, you will find instructions for an alternate way to create a do file.
a) A printed Stata log file documenting that you've completed each of the operations directed below as well as results. As always, be sure to run only your corrected Do file so your printed log file does not contain errors.
b) A printed write-up, which includes typed answers to the questions below.
1. Estimate a fixed effects regression with total expenditures per pupil as the dependent variable. Be sure to use schools as the fixed effect and robust standard errors. Use xtreg and robust (or r). Ask Help.
a. Use the following independent variables:
• percent black
• percent free lunch
• total enrollment
• total enrollment squared
• percent Hispanic
• percent Asian
• percent full-time special education
• percent immigrant
• percent female
• math z score
• year dummies
b. Why are the borough and middle dummies omitted? What would happen if they were included?
3. Now estimate the regression using areg with the absorb option and robust standard errors.
Areg estimates fixed effects by including 711 (one omitted) dummies for each school (but does not show the coefficients for these dummies). Xtreg estimates fixed effects by "deameaning" - that is subtracting each school's mean over the four years from each year's value for every variable and then uses these demeaned values in the regression.
Therefore, one of these estimates (areg vs. xtreg) has more variables in it (more k) and therefore a smaller number of degrees of freedom (n-k-1). In light of this explanation:
What differences can you detect between xtreg and areg, if any?
4. Interpret the coefficient (in the fixed effects context) on percent full-time special education.
ALTERNATE WAY TO WRITE A DO FILE
You can write your do-file another way as well, but if you choose this option, you will need to edit and annotate the final file. The alternative is to type commands into the command box in Stata (or even to use the drop down menu to find commands and put them into the command box). Then you can run each command or set in "real time" to see if it works.
When you are finished, with commands that do and do not work, you will paste them all into a do-file and at that point edit out the wrong commands and also annotate.
a. To create a new file from the commands you've already used:
i. Right click on the header in the Review panel (where all the commands are listed) and click on select all
ii. Right click inside the Review panel and select Send to Do-file Editor
iii. Save this as you would any other file using the .do extension
1. If you save the do-file before the end of your commands, then you will need to add new ones. To do so:
In the panel with the list of commands, select the commands that you want to add to your do-file.
a. Note: you can select multiple commands by holding the Ctrl key
b. Note: this means that you can "pick and choose" the commands you add (so you don't have to include the lines that didn't work)
2. Copy and paste these commands into your working do-file
3. Save the updated do-file
iv. Note: if you don't update your do-file as you go along (see the section above) you will need to re-save this at the end of the session - to save over the initial do-file:
1. Close the do-file you created earlier
2. Right click inside the panel with the list of commands and click on Select All
3. Right click in the panel again and select Save All
4. Save the do-file (using the same name as before) - Stata will ask if you want to replace the existing file, which you do
5. You will then need to open the do-file in the editor and delete any commands that were errors
This solution is comprised of a detailed explanation Regression Analysis in STATA. This solution mainly discussed the different regression models with actual variable, dummy variables and other transformation of variables. This solution explained the fixed regression analysis with option xtreg and areg with option absorb in STATA.