# Midterm rules

- You have an 18-hour window to complete this exam. You must upload both your completed RMD file **and** your knitted HTML file to the GauchoSpace by Thursday 11 July at 11am.
- Late exams will receive a score of 0.
- You may use the internet and any course material (problem sets, section code, lecture slides, video modules, etc.).
- You may **not** communicate with anyone about any concepts, ideas, or questions related to the midterm. Failure to abide by this rule will lead to a 0 in the course.
- The midterm is out of 30 points. There are 2 possible extra credit points. You are encouraged to attempt the extra credit points! The midterm is worth 15% of your final grade.


**GOOD LUCK!**


## Name:


### Reminder
You can write math in RStudio by enclosing it between dollar signs, like so: $\beta_1$. Refer to the explainer "How to write math in RStudio" posted at the top of the GauchoSpace for more information.



***



### Investigating the resource curse

Political scientists and economists have long debated the existence of the "resource curse": the puzzling association between the presence of natural resources in a country and its level of economic development. The resource curse hypothesis posits the following paradox: countries that are rich in natural resources (such as, for example, valuable minerals) are also likely to suffer from worse development outcomes (less GDP, greater violence, etc.). In this exam, we will dig deeper into the resource curse: does it really exist? and what might be driving it?

The data that we will use come from the World Bank. The `development.RData` dataframe contains information on the relative resource abundance and economic outcomes of countries in 2015.

Variable Name  | Description 
------------- | ------------- 
country    | name of country        
NatResourceRents        | total natural resources rents (% of GDP) in 2015
GDPPerCap        | countries' GDP per capita (in US dollars) in 2015

The World Bank further describes total natural resource rents as "the sum of oil rents, natural gas rents, coal rents (hard and soft), mineral rents, and forest rents.'' The variable `NatResourceRents` measures those natural resource rents as a percentage of each country's GDP.


**1. (1 point)**
Set your working directory and load the data-set `development.RData`.

```{r}
# Your code here
```



**2. (3 points total)**
It is best practice to begin by summarizing your data. What is your sample size? (Use code for full credit.) **(1 point)** What is the mean value of `NatResourceRents`? **(1 point)** What is the mean value of `GDPPerCap`? **(1 point)** For full credit, make sure to write your answers with the proper units.

```{r}
# Your code here
```

**Your answers below**



**3. (2 points total)**
What is the range of both of these variables? For full credit, make sure to write your answers with the proper units.

```{r}
# Your code here
```

**Your answers below**



**4. (2 points total)**
Now let's examine the distribution of GDP per capita. Plot a density plot of the `GDPPerCap` variable. **(1 point)** How would you describe this distribution? **(1 point)**

```{r}
# Your code here
```

**Your answer below**



**5. (2 points total)**
Let's start investigating the association between the percentage of GDP that comes from natural resources and the GDP per capita. What is the covariance of `NatResourceRents` and `GDPPerCap`? **(1 point)** What is the correlation? **(0.5 points)** How would you interpret the correlation? **(0.5 points)**

```{r}
# Your code here
```

**Your answers below**



**6. (2 points total)**
You want to know whether the percentage of natural resource rents in a country's GDP predicts their GDP per capita. In this case, what is your independent variable? **(1 point)** What is your dependent variable? **(1 point)**

**Your answers below**



**7. (1 point)**
Given this set-up, write the bivariate regression model that we want to estimate.

**Your answer below**



**8. (2 points total)**
Given this set-up, what is your null hypothesis (in words and in math)? **(1 point)** Write down your two-sided alternative hypothesis (in words and in math). **(1 point)**

**Your answers below**



**9. (2 points total)**
Plot the relationship between % of natural resource rents in GDP and GDP per capita using a scatterplot. For full credit, you must label all axes in your graph, including the title. **(1 point)** Add a line of best fit to your scatter plot. **(1 point)**

```{r}
# Your code here
```



**10. (4 points total)**
Run a regression of GDP per capita on percentage of natural resource rents and show the regression table. **(1 point)** Interpret the coefficient on the intercept. **(1 point)** Interpret the slope coefficient. **(2 points)** For full credit, you must precisely interpret the coefficients using the correct units.

```{r}
# Your code here
```

**Your answers below**



**11. (2 points total)**
Interpret the p-value on your slope coefficient. **(1 point)** Interpret your findings in terms of your hypotheses: do you find evidence for or against the null hypothesis? **(1 point)**

**Your answers below**



**Extra credit (1 point)**
Interpret the p-value on your slope coefficient in terms of Type I and Type II errors.

**Your answer below**



**12. (3 points total)**
Can you say that we have identified a causal relationship between natural resource rents and GDP per capita? **(1 point)** Why or why not? For full credit, follow the steps we have discussed for ascertaining whether a causal claim is warranted, including discussion of endogeneity, confounders, and biases. **(2 points)**

**Your answers below**



**Extra credit (1 point)**
Let's imagine for a moment that the debate on the resource curse was settled (it definitely is not!) and that we wanted to test a one-sided alternative hypothesis. Hypothetically, if I were to set the following null hypothesis: $H_0: \beta_1 \leq 0$, what should my corresponding one-sided alternative hypothesis be? For full credit, write your answer in words and in math.

**Your answers below**




### Analyzing a research paper

**13. (4 points total)**
We read an article last week by Kalla and Broockman (2016). What is their research question, and what is their research design? **(1 point)** What do they find? **(1 point)** Are they able to infer a causal effect? **(1 point)** Why or why not? **(1 point)** (100 words max)

**Your answers below**
