stata代写-EC 356
时间:2022-05-08
Extra Credit Assignment
Shomik Ghosh
EC 356: Labor Economics
Due May 8th, 2022 at 11:59PM
This assignment is for extra credit. You may NOT work on this assignment with other people. If any ev-
idence that you have worked on this with other people comes to light, you will get a 0 for this assignment.
This assignment is worth up to 20 extra credit points and will be added to your lowest score(s) in prob-
lem sets or exams. For example, if you received a 60 on the midterm, this will add points to make that
an 80. Students who have ”capped out” can only receive up to 5 points beyond their final score. For exam-
ple, if you have 100 on everything you will get 5 extra credit points at most. This will NOT apply to the final.
This assignment is an empirical exercise that requires the use of external software. You can do this in
any statistical software you are comfortable in. The one I recommend is R, which can be downloaded here:
(https://www.r-project.org/) I personally use a GUI for R called R-Studio, which can be downloaded here.
(https://www.rstudio.com/products/rstudio/). These are both free and can be run in Windows, MacOS, or
Linux.
Another software that is recommended is Stata. Stata, however, is not free. You can purchase it, but you
can also get a free trial for seven days here: (https://www.stata.com/customer-service/short-term-license/).
You can also get it elsewhere. To my knowledge, no machines that undergrads can access can run Stata.
For submission, you have a few options. R-Studio has an option to ”knit” your files with code into an
html, word, or PDF document. Stata can also generate log files. You should submit these if possible. I
would also accept a word/pdf document that have the steps and images/code of what you did in between
each step and question. Regardless of what you do, make sure you present it neatly - that will be a factor
in your grade.
1
Steps
1. Use ”Small CPS, 2017.dta”, in the same folder this file is found. Stata can import this natively, R
needs to use the haven package to do so.
2. Generate an experience variable, which in this context would be “age - grade - 5”
3. How many people of each race are in the dataset?
4. American Indians are the smallest group in this sample - combine them with the other category.
5. Generate a nonwhite variable, which is 1 if someone isn’t white and 0 if someone is.
6. Compute means of hours, grade, experience and union for women and for race. Try to present
your results neatly, in a table or just in a document.
7. Regress the log of rwage on female, race dummy variables, and hispanic.
8. Test for the joint significance of the three race effects.
9. Now add the following variables to the regression: hours, grade, experience, experience-squared, union,
and occupation. If you add a dummy variable, make sure to take the appropriate steps to account for
it.
10. Test for the joint significance of the occupation effects.
11. Now in the regression you did in step (9), replace race with nonwhite.
Questions
1. How many workers in the sample report being both black and Hispanic?
2. How big is the gender hours gap in the data?
3. How big is the Asian=white schooling gap in the data?
4. What are the estimated effects of sex, race, and ethnicity in the step (7) regression? Report all
coefficients and indicate which coefficients are statistically significant. Are the race effects on wages
jointly significant?
5. What are the estimated effects of sex, race, hours, grade, and experience in the step (9) regression?
Report all coefficients and indicate whether each coefficient is statistically significant. Are the race
effects on wages jointly significant?
6. In the final regression, what is the coefficient on nonwhite? Is it statistically significant?
7. There are different ways we can extend this regression and make it more robust and informative. Please
describe one way in detail.
2
Helpful Commands, Tips, and Tricks
• In both R and Stata, it is helpful to set your working directory to the folder you are doing work in.
Stata does this through the cd command whereas R does this through the setwd command.
– cd “ ∼/Documents/Assignment/Extra Credit”
– setwd(“∼/Documents/Assignment/Extra Credit”)
• To do regressions in R, you must define a linear model in the code (lm) and run it. In Stata you simply
have to write ”regress” followed by a list of variables.
• It is helpful to clear your workspace if you want to run your code anew.
• For R, you might want to install the dplyr library to do groupings. This isn’t necessary but it’s very
helpful.
• While not necessary, consider using the following packages to make your regression output nicer in R:
finalfit, tidyverse, and stargazer. In Stata, investigate the eststo command. Again, this is not necessary
considering you can take screenshots of the output and put them in a word file, though those who do
might get a little more extra credit. Consider if it’s worth it.
• Google and Stackexchange are your friends!
3

essay、essay代写