The assignment is worth 100 points. There are 27 questions. You should have the following packages installed:
library(tidyverse)
library(patchwork)
library(fixest)
library(reshape)
In this problem set you will summarize the paper “Do Workers Work More if Wages Are High? Evidence from a Randomized Field Experiment” (Fehr and Goette, AER 2007) and recreate some of its findings.
[Q1] What is the main question asked in this paper?
The main question being asked concerns the actual effect higher wages has on the supply of labor.
[Q2] Recall the taxi cab studies where reference dependence is studied using observational data. What can an experimental study do that an observational study can’t?
An experimental study has more control over potentially influencing factors present in observational studies and allows for any variation to be better accounted for.
[Q3] Summarize the field experiment design.
The field experiment took place over three time periods for all individuals included in the study. These consisted of a baseline period, a treatment period, and a control period. Each messenger took part in all three periods, and the amount of revenue earned was recorded during each period, which allowed for a measure of effort to be calculated.
[Q4] Summarize the laboratory experiment design. Why was it included with the study?
The laboratory experiment intended to determine individual loss-aversion preferences to see if this behavior drove the negative effect of the wage increase on effort per shift. The experiment presented the messengers with two lotteries, and their decisions enabled the researches to classify a degree of loss-aversion.
[Q5] Summarize the main results of the field experiment.
It was found -on average- that by increasing the wage, the workers worked more hours, but less effort was expended during these additional hours. Also, the degree of loss-aversion plays a significant role in the negative effect of wages on effort.
[Q6] Summarize the main results of the laboratory experiment.
The laboratory experiment found that one-third of the workers were loss averse. This one-third clearly represented the main findings of the field experiment.
The messengers who did not display loss-averse preferences did not change their effort per shift throughout the trial.
[Q7] Why are these results valuable? What have we learned? Motivate your discussion with a real-world example.
These results are incredibly valuable. They show that when higher wages are offered, more hours will be worked by employees, however with decreased marginal productivity. If an employer were looking to maximize output through higher wages, they might be better off hiring new employees without a pre-existing daily reference point.
In high school our football team would sell raffle tickets with coupons to the local community. If one summer day a student determined they were leaving home and not coming back until they sold 10 tickets, no matter if it took them five hours or eight (on coaches orders), they would have a point of reference and the amount of effort they would expend depends on their relative position to this point. If student A hits hour six with only 8 tickets sold, they will make great effort to sell their final 2 tickets. In contrast, if student B finds one person who buys all 10 tickets in the first hour, they will have little motivation to keep trying to sell.
These statements hold for individuals who exhibit loss-averse preferences. Understanding these differences in preferences can help managers that’re able to recognize and make use of the implications.
Use theme_classic()
for all plots.
For this section please use dailycorrs.csv
.
= read_csv("data/dailycorrs.csv") dailycorrs
[Q8] 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
.
<- dailycorrs %>%
p1 ggplot(aes(x=logv, y=logf))+
geom_point() +
geom_smooth(method='lm', se=FALSE)+
ggtitle("Earnings by Company")+
xlab("Veloblitz") + ylab("Flash") +
theme_classic()
[Q9] 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
.
# Transforming
= t(dailycorrs)
t1 = melt(t1)
t2 <- t2[,c(1,3)]
q9den
#dailycorrs %>% pivot_longer(everything())
<- q9den %>%
p2 ggplot(aes(x=value, fill=X1))+
geom_density(alpha=0.6)+
scale_fill_discrete(name="Delivery Service",
labels=c("Veloblitz","Flash"))+
labs(title="Revenue Estimations",
x="Value", y="Density")+
theme_classic()
[Q11] Now combine both plots using
library(patchwork)
and label the plots with letters.
<- p1 + p2
patchwork + plot_annotation(
patchwork tag_levels = 'A',
)
For this section please use tables1to4.csv
.
= read_csv("data/tables1to4.csv") tabz
On page 307 the authors write:
“Table 2 controls for individual fixed effects by showing how, on average, the messengers’ revenues deviate from their person-specific mean revenues. Thus, a positive number here indicates a positive deviation from the person-specific mean; a negative number indicates a negative deviation.”
[Q12] Fixed effects are a way to control for heterogeneity across individuals that is time invariant. Why would we want to control for fixed effects? Give a reason how bike messengers could be different from each other, and how these differences might not vary over time.
Some individuals have a better work ethic, a better/more efficient bicycle, or any wide possibility of differences unique to them as an individual. These individual-specific differences are why we control for fixed effects. This allows us to compare an individuals behavior to their usual, unique self, over time.
[Q13] Create a variable called
totrev_fe
and add it to the dataframe. This requires you to “average out” each individual’s revenue for a block from their average revenue: \(x_i^{fe} = x_{it} - \bar{x}_i\) where \(x_i^{fe}\) is the fixed effect revenue for \(i\).
'totrev_fe'] <- tabz$totrev / tabz$shifts
tabz[
<- tabz %>%
fe group_by(fahrer) %>%
summarize(totrev - mean(totrev))
'totrev_fe'] <- fe[,2] tabz[
[Q14] Use
summarise()
to recreate the findings in Table 2 for “Participating Messengers” using your new variabletotrev_fe
. (You do not have to calculate the differences in means.)In addition to calculating the fixed-effect controled means, calculate the standard errors. Recall the standard error is \(\frac{s_{jt}}{\sqrt{n_{jt}}}\) where \(s_{jt}\) is the standard deviation for treatment \(j\) in block \(t\) and \(n_{jt}\) are the corresponding number of observations.
(Hint: use
n()
to count observations.) Each calculation should be named to a new variable. Assign the resulting dataframe to a new dataframe calleddf_avg_revenue
.
<- tabz %>%
df_avg_revenue group_by(block, odd) %>%
summarize(mean = mean(totrev_fe),
se = sd(totrev_fe) / sqrt(n()))
[Q15] Plot
df_avg_revenue
. Use points for the means and error bars for standard errors of the means.
To dodge the points and size them appropriately, use
geom_point(position=position_dodge(width=0.5), size=4)
To place the error bars use
geom_errorbar(aes(
x=block,
ymin = [mean] - [se], ymax = [mean] + [se]),
width = .1,
position=position_dodge(width=0.5))
You will need to replace [MEAN]
with whatever you
named your average revenues and [SE]
with whatever you
named your standard errors.
%>%
df_avg_revenue ggplot(aes(x=factor(block), y=mean, color=factor(odd))) +
geom_point(position=position_dodge(width=0.5), size=4)+
scale_colour_discrete(name="Group",
labels=c("B","A","Not Assigned"))+
scale_x_discrete(breaks = 1:3,
name = NULL,
labels = c("Pre Experiment", "Period 1", "Period 2"))+
geom_errorbar(aes(
x=block,
ymin = mean - se , ymax = mean + se),
width = .1,
position=position_dodge(width=0.5)) +
ggtitle("Average Revenues")+
ylab("Revenue (fixed effect)") +
theme_classic()
[Q16] Interpret the plot.
This plot shows that when the treatment group had the opportunity to receive higher wages, they earned significantly more than their average earnings. When compared to the control group and groups not included in the experiment, it’s clear to see the effect higher wages had on revenues earned.
[Q17] Recreate the point estimates in Model (1) in Table 3 by hand (you don’t need to worry about the standard errors). Assign it to object
m1
. Recreating this model requires you to control for individual fixed effects and estimate the following equation where \(\text{H}\) is the variablehigh
, \(\text{B2}\) is the second block (block == 2
) and \(\text{B3}\) is the third block (block == 3
):
\[ y_{ijt} - \bar{y}_{ij} = \beta_1 (\text{H}_{ijt} - \bar{\text{H}}_{ij}) + \beta_2 (\text{B2}_{ijt} - \bar{\text{B2}}_{ij}) + \beta_3 (\text{B3}_{ijt} - \bar{\text{B3}}_{ij}) + (\varepsilon_{ijt} - \bar{\varepsilon}_{ij}) \]
<- tabz %>%
byHand group_by(fahrer) %>%
filter(maxhigh == 1) %>%
summarize(left = totrev - mean(totrev),
b1 = high - mean(high),
b2 = block2 - mean(block2),
b3 = block3 - mean(block3))
<- byHand %>%
m1 lm(left~ b1 + b2 + b3 - 1, data=.)
summary(m1)
##
## Call:
## lm(formula = left ~ b1 + b2 + b3 - 1, data = .)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4376.3 -656.5 46.9 831.3 3355.6
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## b1 1033.6 272.1 3.799 0.000229 ***
## b2 -211.0 311.3 -0.678 0.499293
## b3 -574.7 305.6 -1.880 0.062447 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1245 on 121 degrees of freedom
## Multiple R-squared: 0.1232, Adjusted R-squared: 0.1015
## F-statistic: 5.669 on 3 and 121 DF, p-value: 0.001147
[Q18] Now recreate the same point estimates using
lm
and assign it to objectm2
. You are estimating the model below where where \(\text{F}_i\) is the dummy variable for each messenger (fahrer
). Make sure to cluster the standard errors at the messenger level. (Uselmtest
andsandwhich
for this.)
\[ y_{ijt} = \beta_0 + \beta_1 \text{H}_{ijt} + \beta_2 \text{B2}_{ijt} + \beta_3 \text{B3}_{ijt} + \sum_{i=1}^{n} \alpha_i \text{F}_i + \varepsilon_{ijt} \]
<- tabz %>%
myDummy group_by(fahrer) %>%
filter(maxhigh == 1) %>%
summarize(actual = totrev,
left = totrev - mean(totrev),
b1 = high - mean(high),
b2 = block2 - mean(block2),
b3 = block3 - mean(block3),
dumVar = sum(fahrer))
<- myDummy %>%
m2 lm(actual~ b1 + b2 + b3 + factor(fahrer) - 1, data=.)
summary(m2, cluster = ~fahrer)
##
## Call:
## lm(formula = actual ~ b1 + b2 + b3 + factor(fahrer) - 1, data = .)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4376.3 -656.5 46.9 831.3 3355.6
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## b1 1033.6 336.7 3.070 0.002937 **
## b2 -211.0 385.3 -0.548 0.585547
## b3 -574.7 378.2 -1.519 0.132639
## factor(fahrer)1 1694.3 889.8 1.904 0.060540 .
## factor(fahrer)2 2131.0 889.8 2.395 0.018995 *
## factor(fahrer)3 2441.5 889.8 2.744 0.007513 **
## factor(fahrer)5 465.2 1089.8 0.427 0.670639
## factor(fahrer)6 3231.8 889.8 3.632 0.000498 ***
## factor(fahrer)7 2444.5 889.8 2.747 0.007444 **
## factor(fahrer)8 1587.3 889.8 1.784 0.078284 .
## factor(fahrer)9 5606.5 889.8 6.301 1.57e-08 ***
## factor(fahrer)14 2578.3 889.8 2.898 0.004865 **
## factor(fahrer)15 1654.3 889.8 1.859 0.066727 .
## factor(fahrer)18 3021.7 889.8 3.396 0.001073 **
## factor(fahrer)19 4353.3 889.8 4.892 5.16e-06 ***
## factor(fahrer)21 1180.2 889.8 1.326 0.188565
## factor(fahrer)22 4649.9 889.8 5.226 1.38e-06 ***
## factor(fahrer)23 5024.5 889.8 5.647 2.48e-07 ***
## factor(fahrer)24 3453.5 889.8 3.881 0.000214 ***
## factor(fahrer)25 1755.5 889.8 1.973 0.052014 .
## factor(fahrer)28 1544.1 889.8 1.735 0.086583 .
## factor(fahrer)30 3251.8 889.8 3.654 0.000462 ***
## factor(fahrer)31 956.3 889.8 1.075 0.285761
## factor(fahrer)32 1168.2 889.8 1.313 0.193037
## factor(fahrer)33 3867.5 889.8 4.346 4.08e-05 ***
## factor(fahrer)34 10801.3 889.8 12.139 < 2e-16 ***
## factor(fahrer)35 1630.3 889.8 1.832 0.070696 .
## factor(fahrer)36 3749.2 889.8 4.213 6.63e-05 ***
## factor(fahrer)37 3888.3 889.8 4.370 3.75e-05 ***
## factor(fahrer)38 3531.2 889.8 3.968 0.000158 ***
## factor(fahrer)42 5632.3 889.8 6.330 1.38e-08 ***
## factor(fahrer)44 2216.2 889.8 2.491 0.014851 *
## factor(fahrer)45 2264.1 889.8 2.544 0.012896 *
## factor(fahrer)49 2738.5 889.8 3.078 0.002868 **
## factor(fahrer)50 8285.0 889.8 9.311 2.41e-14 ***
## factor(fahrer)51 6983.3 889.8 7.848 1.72e-11 ***
## factor(fahrer)52 5972.6 889.8 6.712 2.64e-09 ***
## factor(fahrer)53 5127.3 889.8 5.762 1.53e-07 ***
## factor(fahrer)55 2670.6 889.8 3.001 0.003598 **
## factor(fahrer)56 3456.1 889.8 3.884 0.000212 ***
## factor(fahrer)57 4165.8 889.8 4.682 1.16e-05 ***
## factor(fahrer)58 3047.5 889.8 3.425 0.000978 ***
## factor(fahrer)60 2625.3 889.8 2.950 0.004175 **
## factor(fahrer)61 2359.0 889.8 2.651 0.009691 **
## factor(fahrer)63 1474.5 1089.8 1.353 0.179918
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1541 on 79 degrees of freedom
## Multiple R-squared: 0.9126, Adjusted R-squared: 0.8628
## F-statistic: 18.32 on 45 and 79 DF, p-value: < 2.2e-16
[Q20] Now use
feols
to recreate Model (1), including the standard errors. Assign your estimates to the objectm3
. You are estimating the model below where where \(\alpha_i\) is the individual intercept (i.e. the individual fixed effect):
\[ y_{ijt} = \alpha_i + \beta_1 \text{H}_{ijt} + \beta_2 \text{B2}_{ijt} + \beta_3 \text{B3}_{ijt} + \varepsilon_{ijt} \]
<- byHand %>%
m3 feols(left~ b1 + b2 + b3 | factor(fahrer) , ssc = ssc(fixef.K = 'full'), data=.)
summary(m3)
## OLS estimation, Dep. Var.: left
## Observations: 124
## Fixed-effects: factor(fahrer): 42
## Standard-errors: Clustered (factor(fahrer))
## Estimate Std. Error t value Pr(>|t|)
## b1 1033.560 326.854 3.162145 0.002945 **
## b2 -210.973 497.250 -0.424278 0.673581
## b3 -574.713 545.675 -1.053214 0.298411
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 1,230.2 Adj. R2: -0.365108
## Within R2: 0.123224
[Q21] Compare the estimates in
m1
,m2
andm3
. What is the same? What is different? What would you say is the main advantage of usingfeols()
?
For all three models, the point estimates are the same, and the standard errors are different for all. The advantage of using feols() is that the standard errors calculated by the model account for the variation among individuals, ie the fixed effect.
[Q22] Explain why you need to cluster the standard errors.
In this case, the standard errors are clustered among individuals. For a model to accurately describe what’s being measured, it’s necessary for there to be clear distinction between individual A, individual B, etc., due to their differing preferences. If individual A exhibits loss-averse preferences while B does not, then individual A will show less effort once their point of reference is reached, whereas individual B likely wont. Thus, the individuals will have different standard errors, which clustering accounts for.