---
title: "Problem Set 1"
format: html
author: "Your Name Here"
date: "`r format(Sys.time(), '%B %d, %Y')`"
---


```{r setup, include=FALSE}
options(width=80)
knitr::opts_chunk$set(echo = TRUE,out.width = 40, tidy=T, tidy.opts=list(width.cutoff=60)) #This code should automatically wrap text when knitting to pdf. 
``` 

# Introduction

 *Welcome to your first problem set. It consists of two sections. The first asks you to analyze data on international development. The second asks conceptual questions about political science methods. Please be sure that you answer every question(and each subquestion)thoroughly.* 
 
 *Give yourself plenty of time to complete the assignment (You will need to build in time for R frustration, freakouts, celebrations, etc.) Please fill in your answers to each question below where it is written. For questions that require coding with R complete your coding in the sections provided and write out answers, if necessary, in the text section. Remember to render as you go and be sure the work you turn in is your own.*
 
 
 *Please submit both your html file and the quarto file on the course website before the deadline of 23:59 on Friday, July 10th. Label your file with pset#_name (ie pset1_colin.html) *
 
# Part 1 - Data Analysis
 
This week we are going to look at some development data from the world bank and other sources. 

The datset is development.Rdata and the codebook(development_codebook.csv) gives information on each variable. Most data are from 2022.   This is a large dataset you can consider using for your final project. 

1. *Set up: Load the world bank dataset.*
```{r}

```


2. *A first look at the data:  a) Show the first few rows of the data b) How many observations are in this dataset? c) How many variables? d) show the names of each of the variables.*
```{r}

```

3. *Descriptive statistics:  Lets look at the  variable wbl_index. This is a composite measure that summarizes how legal frameworks shape women's economic opportunities*

*a) Find the mean, median, variance, max, and min for this indicator. In cases where a variable has missing values R will return an NA. Just add , na.rm=T (ie mean(dataset$variablename, na.rm=T)) to your command to tell it to ignore these values.  b) Produce a histogram of wbl_index (Be sure that it is properly labeled) The use of colors etc. is encouraged.*
```{r}

```

4. *Look through the codebook and find a variable you find interesting. Repeat 3a and 3b above. What do you find interesting or surprising*

```{r}

```


5. *Looking at relationships:  We might hypothesize that as women's economic opportunities increase, the fertility rate goes down. In this scenario . . . a) What is the independent variable b) What is the dependent variable? c)Create a scatter plot of the relationship(Be sure each is on the correct axis and that everything is labelled) d) add a trend line for the hypothesized relationship e) How would you describe the relationship? f)Is the relationship causal? why or why not? *
*Bonus: Use country code instead of dots in the scatterplot in the scatterplot*
```{r}

```



6. *Alternative Explanations:  Using variables from the dataset think of your own alternative hypothesis for the rate of fertility rate  a) What is the new independent variable  b)Create a scatter plot of the relationship c) add a trend line for the hypothesized relationship d) How would you describe the relationship? Does it support your theory. f)Is the relationship causal? why or why not?*

```{r}

```

7. *Returning to the relationship in question 5. You question if the same relationship holds in East Asia & Pacific. Run the same analysis just using East Asia and Pacific countries.*
```{r}

```



6. *New Question: We're interested in how the aging population shapes health care spengin. a) Create a new variable that is the percentage of the population that is over 64 years old (hint: check the codebook).b) find the mean, median, and variation of this new variable c) create a boxplot comparing the percentage of old folks in different regions of the world  measure?*
```{r}

```

7.*Your turn - Please take your time here.*  

*We might hypothesize that as the percent of older folks increase health care spending increases. In this scenario . . . a) What is the independent variable b) What is the dependent variable? c)Create a scatter plot of the relationship(Be sure each is on the correct axis and that everything is labelled) d) add a trend line for the hypothesized relationship e) How would you describe the relationship? f)Is the relationship causal? why or why not?*
```{r}

```


8. *Using the data come up with your question and hypothesis.a) Explore each variable you chose (make sure we haven't used them yet and that they are different from your friends) b) graph the relationship and tell me what it means.* 

```{r}



```

 
# Part 2 - Conceptual Questions

1.In ways your friends would understand, explain why quality research is important for public policy.



2. In ways your parents would understand,under what conditions can we claim causality.



3. In ways your neighbors would understand, what is the value of descriptive research?




4.Imagine you are running a research project on the effect of education on youth political participation. List some of the factors (at least 3) that could lead to an endogeneity problem.




5. What is a possible **mechanism** for the observed relationship between women's economic opportunities and fertility rate? What is a mechanism in public policy research?



6. How long(hours) did this problem set take you?And who else in the class did you work with while completing it?



7. Anything else Dr. Colin should know about you, this class, CMU, life, etc? Feel free to vent


