---
title: "Homework 1"
subtitle: "Evaluating Modernization Theory"
---

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

## Overview

For this assignment, you are going to evaluate modernization theory as laid out in Seymour Martin Lipset's [classic article](https://www-jstor-org.proxygw.wrlc.org/stable/1951731?seq=8) entitled "Some Social Requisites of Democracy: Economic Development and Political Legitimacy." How classic is this article? According to Google Scholar, this piece has been cited more than 11.5 thousand times! 

We are going to use data from V-Dem and modern data viz tools to explore Lipset's hypothesis that economic modernization is highly correlated with democracy. We have already done this to some extent by looking at the relationship between wealth and the polyarchy score. But we are going to broaden things out by looking at other measures of modernization and democracy contained in the V-Dem dataset.

Before starting on this assignment, you will want to have a look at the V-Dem [codebook](https://www.v-dem.net/static/website/img/refs/codebookv111.pdf). Look through the sections titled "V-Dem Democracy Indices" (section 2 of the codebook) and "Background Factors (E)." There are five democracy indicators, one of which is the polyarchy index. There are a number of background factors, many of which pertain to economic modernization. We are going to be looking at the relationship between these two sets of variables. In the code book, you will also find a list of country names and codes, which will be useful for downloading and filtering the data.

Now have a look at "Some Social Requisites of Democracy" and in particular pay attention to the indicators in Table II and the discussion surrounding them. Think of each indicator (e.g. urbanization, education, etc.) as a sub-hypothesis of his theory. Which of these sub-hypotheses about modernization do you think is most compelling? Which would you like to test?

You have the option of doing this assignment in Posit Cloud or downloading the project folder and working locally. Either way you must submit your zipped project folder with the rendered HTML file included (see submission instructions at the end of the document) to Blackboard. 

## Step 1: Gather your data (20 pts)

*Insert a code chunk below this paragraph and label it. Use the `vdemdata` package to download data for your analysis. Since we already looked at the polyarchy score and wealth in class, you need to use a different measure of democracy and a different background factor for your analysis. Use a `select()` verb to include country, year, region (`e_regionpol_6C`), at least one of the other four measures of democracy, and one background factor that is not per capita GDP. Store your data in an object called `dem_data`. Pipe in a mutate() verb and use `case_match()` to label the regions. Review [module 3.1](https://quant4ia.rocks/modules/module-3.1) if you are confused on how to do this.*

## Step 2: Make a line chart showing country trends (20 pts)

*a) Insert a code chunk below this paragraph and label it. Filter your `dem_data` to include three or four countries at various levels of economic development and create a line chart of your democracy indicator. See the [World Bank country classifications](https://blogs.worldbank.org/en/opendata/understanding-country-income--world-bank-group-income-classifica) by income level to make your selections. Save the data as a new data frame called `dem_data_line`.* 

**Note: From here on out I will expect you to know to add a code chunk and label it. So I won't keep repeating that portion of the instructions.**

*b) Make a line chart using `ggplot2`. Be sure to specify `x = `, `y = ` and `color =` in your aes() call and use `geom_line()` to create the chart. Add a colorblind-friendly color map using `viridis`. Now add appropriate axis labels, a title and a caption.*

*c) In a few sentences, interpret your chart. Have the more developed countries achieved a higher level of democracy? Put your answer right below this line in markdown text.*

## Step 3: Make a bar chart comparing regional levels (20 pts)

*a) Going back to your original `dem_data` data frame, filter the data for a single year and then group by region and summarize your democracy indicator by mean. Save the new data in an object called `bar_chart_data`.* 

*b) Use `ggplot()` and `geom_col()` to create a bar chart showing levels of democracy across the regions with `bar_chart_data`. Make sure to add appropriate axis labels, a title and a caption. Change the fill color and add a theme to spruce it up a bit.* 

*c) Interpret your bar chart. Do you see evidence that more developed regions have higher levels of democracy?*

## Step 4: Make a scatter plot to show  (20 pts)

*a) Start with the `dem_data` data frame again, Now take an average of multiple years using `group_by()` and `summarize()` to analyze. If you choose a recent period, make sure that the data are available. Some of the background variables in V-Dem are not entirely up to date. You can check the availability of the data by looking at the V-Dem codebook or using `glimpse()` or `View()` to look at your data. Save your your data in a new object called `dem_data_scatter`.*

*b) Now build a scatter plot with `ggplot2`. Put your modernization-related variable (background variable) on the x-axis and your measure of democracy on the y-axis and color the points by region. Add a trend line with `geom_smooth()`. Add appropriate labels and a `viridis` color map. Change the theme to `theme_minimal`.*

## Step 5: Conclusion (20 pts)

*Render your document and write a brief conclusion to your analysis. What did you find? Did you find support for Lipset's theory? What are the limitations of your analysis?*

## Step 6: Bonus questions (one point each)

*a) Facet wrap your scatter plot by region.*

*b) Remove the `facet_wrap()` call and display the relationship for one region and use `geom_text()` to label your points.*

*c) Remove the text labels and make your scatter plot interactive using `ggplotly()`. Make sure that your tooltip includes the information that you want to display to the user.*

*d) Add annotation to your plot using hline() or vline() to highlight a significant point in your data, like the mean or some other significant value.*

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

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

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