---
title: "Homework 3"
subtitle: "Replicating Fearon and Laitin (2003)"
author: "Your Name"
format: html
---

::: {.callout-note appearance="minimal"}
[Download the `.qmd` file for this assignment](https://raw.githubusercontent.com/eteitelbaum/quant4ia/main/assignments/homework-3.qmd)
:::

In this homework assignment, we are going to be exploring the hugely influential article by Fearon and Laitin (2003) on civil war onset. Click [here](https://www-jstor-org.proxygw.wrlc.org/stable/3118222?seq=11) to view the original article and see Table 1 for the model that we will be replicating. 

## Load the Data

Load the data which is included in the `fl_data_model1.csv` file in the Homework 3 assignment folder. 

```{r}

```

The unit of analysis is the country-year. 

### Outcome Variable

- `onset` - Whether a country-year experienced civil war onset (1 = yes, 0 = no)

### Main Predictors

- `warl`- Whether had a war ongoing in the previous year
- `gdpenl` - GDP per capita (not logged) 
- `lpopl1` - The log of population lagged by one year 
- `lmtnest` - The log of the percentage of country that has mountainous terrain 
- `ncontig` - An indicator for noncontiguous state
- `Oil` - An indicator for whether the country is an oil exporter
- `nwstate` - An indicator for whether a country was created in the last two years
- `instab` - An indicator for whether the Polity score changes by 3 or more in a given year 
- `polity2l` - The Polity2 democracy score
- `ethfrac` - Ethno-linguistic fractionalization index
- `relfrac` -  Religious fractionalization index

## Replicate Model 1 from Fearon and Laitin (20%)

Run the first model (Model 1) from Table 1 of the Fearon and Laitin article. Use `summary()` to view the results. Interpret the coefficient on the Oil exporter variable. How much does being an oil exporter increase the risk of conflict onset? 

```{r}

```

## Display the Results as a Coefficient Plot (20%)

Now use the `modelplot()` function from the `modelsummary` package to display the results as a coefficient plot. 

When making your coefficient plot, start with the coefficient map. You might want to write it in the order that you'd like to see the coefficients displayed and then reverse it so that you can use the same map for your regression table below.

Be sure to load the `modelsummary` and `ggplot2` packages before you get started with the rest of your code.

Interpret the results. Which predictor has largest positive effect on the probability of conflict onset? Which one has the strongest negative effect? 

```{r}

```

## Create a Regression Table (20%)

Do stepwise regressions with different categories of regressors based on the same model to see how things change as you put different sets of variables into the model. Show the results of your models in separate columns in a regression table. 

**Step one:** Run your `glm()` models and store them as objects. Here you might want to summarize them with `summary()` or `tidy()` from the `broom` package as you go along. 

```{r}

```

**Step two:** Save your models as a list and set up your caption and reference note. 

```{r}

```

**Step three:** Call `modelsummary` to display the table as a `gt` object. 

```{r}

```

**Step four:** Briefly interpret your results. What changes as you add different categories of variables to the model? Do any results become significant that were not significant before? 

## Show Odds Ratios and Interpret (20%)

Now make the table display odds ratios instead of coefficients and interpret one or two of the coefficients that you find interesting. (*Note*: you have already talked about Oil, so choose a different one for this part.)

```{r}

```

## Display Predicted Probabilities (20%)

Now display predicted probabilities for a handful of country-years. Filter the data for a particular year and the country cases that you are interested in. Find the predicted probabilities using the `precitions()` function from the `marginaleffects` package. Interpret the results. Why do some of the countries you chose have a higher probability of conflict onset than the others? 

```{r}

```

## Extra Credit (4 pts)

If you would like to do some extra credit, you can try to replicate even more of the F&L analysis. Try replicating the entirety of Table 1 from F&L here using the `fl_xtra_credit.csv` file. Then discuss the results from at least one of the columns.

```{r}

```

::: {.callout-important}
## Submission Instructions

Head over to Blackboard and go to the Homework 3 assignment. Click "Create Submission" and write a brief statement saying that you have submitted the assignment and that all of the work is your own.

From there, upload a compressed (zipped) version of your project folder including the **rendered** HTML file. To compress your project folder, right-click the folder and choose Compress (Mac) or Send to → Compressed (zipped) folder (Windows). Then upload the resulting .zip file.
:::

