代写 R theory Behavioral Economics, Boston College Your name here

Behavioral Economics, Boston College Your name here
Fall 2019
Problem Set 2
The assignment is worth 100 points. There are 26 questions. You should have the following packages installed:
librarytidyverse librarycowplot librarylfe librarystargazer
In this problem set you will summarize the paper Do Workers Work More if Wages Are High? Evidence from a Randomized Field Experiment https:www.aeaweb.orgarticles?id10.1257aer.97.1.298 Fehr and Goette, AER 2007 and recreate some of its findings.
1 Big picture
1. What is the main question asked in this paper?
2. Recall the taxi cab studies where reference dependence is studied using observational data. What can an experimental study do that an observational study cant?
3. Summarize the field experiment design.
4. Summarize the laboratory experiment design. Why was it included with the study?
5. Summarize the main results of the field experiment.
6. Summarize the main results of the laboratory experiment.
7. Why are these results valuable? What have we learned? Motivate your discussion with a realworld example.
2 Theory
Suppose the messengers utility function is
curve to plot the labor supply for wt 0, 10.
3 Replication
Use themeclassic for all plots.
t
vet,xt wtet get,xt
where wt is the wage rate in time t, et is the messengers e!ort, is the marginal utility of lifetime wealth, and g et , xt xte2 is the 22
messengers cost function constant disutility of e!ort and exogenous disutility shock xt N0, . Since xt 0, you can assume xt 0.
8. Show that the messenger chooses a level of e!ort so that the marginal benefit of working equals the marginal cost.
9. Show that the messenger in equilibrium responds to higher wages with higher e!ort.
10. Write an R function that calculates e for di!erent levels of wt . Set default values of 1. Then use curve to plot the labor supply for
wt 0,10.
11. Now suppose utility is given by
vet,xt wtet rget,xt if wtet r wtet rget,xt if wtet r
12. Show that how the messenger in equilibrium responds to higher wages depends on the reference point r. Hint: recall there are three cases to consider.
13. Once more write an R function that calculates e for di!erent levels of wt . Set default values of 1, 2 and r 3. Then use t

3.1 Correlations in revenues across firms
For this section please use dailycorrs.csv .
14. The authors show that earnings at Veloblitz and Flash are correlated. Show this with a scatter plot with a regression line and no confidence
interval. Title your axes and the plot appropriately. Do not print the plot but assign it to an object called p1 . your code here
15. Next plot the kernel density estimates of revenues for both companies. Overlay the distributions and make the densities transparent so they are easily seen. Title your axes and the plot appropriately. Do not print the plot but assign it to an object called p2 .
your code here
16. Now combine both plots using cowplot and label the plots with letters.
your code here
3.2 Tables 2 and 3
For this section please use tables1to4.csv . 3.2.1 Table 2
On page 307 the authors write:
17. Fixed e!ects are a way to control for heterogeneity across individuals that is time invariant. Why would we want to control for fixed e!ects? Give a reason how bike messengers could be di!erent from each other, and how these di!erences might not vary over time.
18. Create a variable called totrevfe and add it to the dataframe. This requires you to average out each individuals revenue for a block from their average revenue: xf e xit x i where xf e is the fixed e!ect revenue for i.
your code here
19. Use summarise to recreate the findings in Table 2 for Participating Messengers using your new variable totrevfe . You do not have to
Table 2 controls for individual fixed e!ects by showing how, on average, the messengers revenues deviate from their personspecific mean revenues. Thus, a positive number here indicates a positive deviation from the person specific mean; a negative number indicates a negative deviation.
ii
calculate the di!erences in means. In addition to calculating the fixede!ect controled means, calculate too the standard errors. Recall the
standard error is sjt where sjt is the standard deviation for treatment j in block t and n jt are the corresponding number of observations. Hint: use n jt
n to count observations. Each calculation should be named to a new variable. Assign the resulting dataframe to a new dataframe called dfavgrevenue .
your code here
20. Plot dfavgrevenue . Use points for the means and error bars for standard errors of the means. Note the following:
To dodge the points and size them appropriately, use geompointpositionpositiondodgewidth0.5, size4 To place the error bars use
geomerrorbaraesxblock, ymin MEAN SE, ymax MEAN SE,width .1,positionpositiondodgewidth0.5 You need to replace MEAN with whatever you named your average revenues and SE with whatever you named your standard errors.
your code here
21. Interpret the plot.
3.2.2 Table 3
22. Recreate the point estimates in Model 1 in Table 3 by hand you dont need to worry about the standard errors. Assign it to object m1 . To recreate this model requires you to control for individual fixed e!ects and estimate the following equation:
ijtij 1ijt ij 2 ijt ij 3 ijt ijijtij

yijt y ij 1Hijt Hij 2B2ijt B2ij 3B3ijt B3ij ijt ij
where H is the variable high , B2 is the second block block 2 and B3 is the third block block 3 . your code here
23. Now recreate the same point estimates ignoring the standard errors again using lm and assign it to object m2 . You are estimating n
yijt 0 1Hijt 2B2ijt 3B3ijt iFi ijt i1
where Fi is the dummy variable for each messenger fahrer . your code here
24. Now use the function felm https:www.rdocumentation.orgpackageslfeversions2.83topicsfelm from the lfe package to recreate Model 1, including the standard errors. Assign your estimates to the object m3 . You are estimating
yijt i 1Hijt 2B2ijt 3B3ijt ijt
where i is the individual intercept i.e. the individual fixed e!ect. Note that the function call works as follows:
felmyx grouping variable 0 clustering varaible, name of data
your code here
25. Compare the estimates in m1 , m2 and m3 . What is the same? What is di!erent? What would you say is the main advantage of using felm ? 26. Recreate all of Table 3 and use stargazer https:cran.rproject.orgwebpackagesstargazervignettesstargazer.pdf to print the results.
your code here