---
title: "R Notebook"
output: html_notebook
---

---
title: "R Notebook"
output:
  html_document:
    df_print: paged
---

## Lab Exercises

In this lab, we're going to investigate potential non-linearities in three different regression models.  To read this in, do the following: 


### Question 1

For this question, we're going to use the **SLID** data in the **car** package.  Here'e we're modeling wages as a function of age, sex and education (all additive).  What I want you to do is investigate any potential non-linearities and fix them if they are problematic.  In your discussion below, identify how you discovered any potential non-linear relationships and why you chose to fix them the way you did. 

You can start by loading the data

```{r, message=F, warning=F}
library(car)
data(SLID)
```

If you want to learn more about the **SLID** data, you can do the following:

```{r, eval=F}
?SLID
```


### Question 2

We're going to do the same thing as above, but for the **Ericksen** which measures the census undercount in different city and state jurisdictions.  I want you to model undercount as a function of minority, poverty, highschool and city.  You can start by loading the data, also in the **car** package.  (Since you already loaded the **car** package above, you don't have to do it again.)

```{r}
data(Ericksen)
```

If you want more information about the Ericksen data, you could do the following: 

```{r, eval=F}
?Ericksen
```

### Question 3

I want you to estimate a model of repression on the polity democracy variable along with gdppc, pop and war.  Identify whether the Polity democracy variable should be treated linearly or otherwise using the methods we talked about in lecture.  Also, evaluate linearity for the other continuous variables as well (i.e., gdppc and pop).  You can start by reading in the data:  

```{r, label=read}
load(file("http://quantoid.net/files/9591/lab2.rda"))
```
The variables included in the data are the following: 

  - ccode Numeric COW country code
  - pop Population
  - gdppc GDP/capita 
  - democracy Behavioral measure of democracy including legislative competition/participation, competitiveness of executive recruitment and participation and others.  This is a continuous measure.  Higher numbers here mean greater levels of democracy.
  - repression Violations of physical integrity rights.  This is the result of a measurement model run on the CIRI data on torture, forced disappearances, extrajudicial killings and political imprisonment.  This is also a continuous measure. Higher numbers here mean higher levels of repression. 
  - civ Civilization code that comes from Henderson and Tucker's article that tries to test the clash of civilizations argument. 
  - war Dummy variable coded 1 if either a civil or interestate war is ongoing and 0 otherwise. 
  - polity_democ Polity IV's democracy variable (integers from 0-10)

