---
title: "Lecture 4 Exercises"
author: "Your Name"
output: html_document
---
```{r setup, message = FALSE, warning = FALSE, echo=FALSE}
knitr::opts_chunk$set(message = FALSE, warning = FALSE, dev="svg", tidy=TRUE,  tidy.opts = list(only.comment=TRUE,  width.cutoff=80))
library(summarytools)
library(dplyr)
```

We're going to use data from the sixth wave of the World Values Survey, we need to load it first from [my website](https://quantoid.net/files/reg3/wvs.rda))

```{r}
load(file("https://quantoid.net/files/reg3/wvs.rda"))
```

This makes an object in your workspace called `wvs`.  To remind, here's a summary of the data: 

```{r, results='asis', eval=FALSE}
codebook <- as.data.frame(sapply(wvs, function(x)attr(x, "label"))) %>% 
  as_tibble(rownames = "varname") %>% 
  setNames(c("varname", "description"))
library(DT)
datatable(codebook)
```

I want you to use the data to answer the following questions. 

### Question 1

Figure out whether the `income` variable (which is income steps) could be used as a quantitative variable to predict `emancip_values`.  Use some other controls in your model.   

- Test whether the model treating `income` as categorical is better. 
- Plot the results to see *how* non-linear they are. 
- See whether a monotone relationship is equally good.


### Question 2

Now, we want to put subjective perceptions of class (the `class` variable) on the left-hand side of the equation.  Pick a few variables that you think might influence someone's self-perceived class. 

- Use the `alsosDV()` function to see whether it behaves linearly relative to the variables on the RHS of the model. 
- Plot the measurement function. 
- What would you do if this were your project? 

