*Use `theme_classic()` for all plots.*

## Correlations in revenues across firms

*For this section please use `dailycorrs.csv`.*

```{r load dailycorrs, message=FALSE, warning=FALSE}dailycorrs = read_csv("../data/fehr_goette_2007/dailycorrs.csv")```>**[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`.```{r q8}# your code here```>**[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`.```{r q9}# your code here```>**[Q11]** Now combine both plots using `library(patchwork)` and label the plots with letters.```{r q11, message=FALSE}# your code here```## Tables 2 and 3

*For this section please use `tables1to4.csv`.*

```{r load tables1to4, message=FALSE, warning=FALSE}# your code here```### Table 2On 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.```{block q12, type = 'written_answer'}[your written answer here]```>**[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$.```{r q13}# your code here```>**[Q14]** Use `summarise()` to recreate the findings in Table 2 for "Participating Messengers" using your new variable `totrev_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 called `df_avg_revenue`. ```{r q14}# your code here```>**[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*```{r, eval = FALSE}geom_point(position=position_dodge(width=0.5), size=4)```*To place the error bars use*```{r, eval=FALSE}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.*```{r q15}# your code here```>**[Q16]** Interpret the plot.```{block q16, type = 'written_answer'}[your written answer here]```### Table 3>**[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 variable `high`, $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})$$ Requirements: use R