# Untitled

unknown
plain_text
2 months ago
3.5 kB
1
Indexable
Never
```**h) Given your analysis, write up a short paragraph describing what the causal mechanism between wealth and corruption could be that would explain the effect that you observe in the data.**

\newpage

## Question 2: Wealth and Infant Mortality

**a) Examine the distribution of per capita income and infant mortality. Make a scatter plot of per capita income and infant mortality. Then compare this to a scatter plot of logged per capita income and logged infant mortality. Which plot appears to represent a linear relationship between the variables?**

```{r}
#| message: false
#| warning: false

ggplot(infmort, aes(x = income, y = infant)) +
geom_point() +
labs(x = "GDP/capita", y = "Infant Mortality") +
theme_bw()

ggplot(infmort, aes(x = log(income), y = log(infant))) +
geom_point() +
theme_bw()
```
The second plot, with logged data, seems to represent more clearly a linear relationship.

**b) Run a regression of log infant mortality on log income controlling for the region of the world (using Asia as the baseline) and whether countries are oil-exporting or not. Interpret the coefficients carefully.**

```{r}
#| message: false
#| warning: false

#Asia as a baseline: factor + relevel
infmort\$region <- as.factor(infmort\$region)
infmort\$region <- relevel(infmort\$region, ref = "Asia")

model_q2b <- lm(log(infant) ~ log(income) + region + oil, data = infmort)

modelsummary(model_q2b,
coef_rename =
c("(Intercept)" = "Intercept",
"log(income)" = "Log GDP/Capita",
"regionAfrica" = "Africa",
"regionAmericas" = "Americas",
"regionEurope" = "Europe",
"oilyes" = "Oil exporting country"),
statistic = "p.value",
stars = TRUE
)
```
**c) Now include an interaction between the oil dummy and income. Interpret the results and try to include informative plots in your writeup. Which model specification do you prefer?**
```{r}
model_q2c <- lm(log(infant) ~ log(income) + region + oil + oil:income, data = infmort)

modelsummary(model_q2c,
coef_rename =
c("(Intercept)" = "Intercept",