The STAR (Student-Teacher Achievement Ratio) Project is a four year
*longitudinal study* examining the effect of class size in early
grade levels on educational performance and personal
development. 

This exercise is in part based on:
 Mosteller, Frederick. 1997. “[The Tennessee Study of Class Size in the 
 Early School Grades.](http://dx.doi.org/10.2307/3824562)” *Bulletin of 
 the American Academy of Arts and Sciences* 50(7): 14-25.
  
A longitudinal study is one in which the same
participants are followed over time.  This particular study lasted
from 1985 to 1989 involved 11,601 students. During the four years of
the study, students were randomly assigned to small classes,
regular-sized classes, or regular-sized classes with an aid.  In all,
the experiment cost around $12 million. Even though the program
stopped in 1989 after the first kindergarten class in the program
finished third grade, collection of various measurements (e.g.,
performance on tests in eighth grade, overall high school GPA)
continued through the end of participants' high school attendance.

We will analyze just a portion of this data to investigate whether the
small class sizes improved performance or not. The data file name is
`STAR.csv`, which is a CSV data file.  The names and
descriptions of variables in this data set are:

--------------------------------------------------------------------------------
 Name                 Description
 -------------------- ----------------------------------------------------------
 `race`               Student's race (White = 1, Black = 2, Asian = 3, 
                      Hispanic = 4,  Native American = 5, Others = 6)
 
 `classtype`          Type of middle school class (small = 1, regular = 2, regular with aid = 3)
 
 `g4math`             Total scaled score for math portion of fourth grade standardized test 
 
 `g4reading`          Total scaled score for reading portion of fourth grade standardized test 
 
 `yearssmall`         Number of years in small classes 
 
 `hsgrad`             High school graduation (did graduate = 1, did not graduate = 0) 
 --------------------------------------------------------------------------------
 
Note that there are a fair amount of missing
values in this data set.  For example, missing values arise because
some students left a STAR school before third grade or did not enter a
STAR school until first grade.

## Question 1

Create a new factor variable called `type` in the data
  frame.  This variable should recode `classtype` by changing
  integer values to their corresponding informative labels (e.g.,
  change 1 to `small` etc.).  Similarly, recode the
  `race` variable into a factor variable with four levels
  (`white`, `black`, `hispanic`, `others`) by
  combining Asians and Native Americans as the `others`
  category.  For the `race` variable, overwrite the original
  variable in the data frame rather than creating a new one.  Recall
  that `na.rm = TRUE` can be added to functions in order to
  remove missing data.
  
  Run following scripts to get the data:
```{r}
library(devtools)
install_github("kosukeimai/qss-package", build_vignettes = TRUE)
library(qss)
data(STAR,package="qss")
```
  
  
## Answer 1

```{r}
 
```

## Question 2

How does performance on fourth grade reading and math tests for
  those students assigned to a small class in kindergarten compare
  with those assigned to a regular-sized class (only for those without aid)?  Do students in the
  smaller classes perform better?  Use means to make this comparison
  while removing missing values.  
  Make sure you call them ``dif_read`` and  ``dif_math``
   
## Answer 2

```{r}
 
```

## Question 2.1
Give a brief substantive
  interpretation of the results.  To understand the size of the
  estimated effects, compare them with the standard deviation of the
  test scores.

## Answer 2.1
 

```{r}
 
```

 

## Question 3

Some students were in small classes for all four years that the
  STAR program ran. Others were assigned to small classes for only one
  year and had either regular classes or regular classes with an aid
  for the rest. How many such students of each type are in the data
  set?  Create a contingency table of proportions using the
  `type` and `yearsmall` variables.  Does participation
  in more years of small classes make a greater difference in test
  scores?  Compare the average and median reading and math test scores
  across students who spent different numbers of years in small
  classes.

## Answer 3

```{r}
 
```
 

## Question 4

We examine whether the STAR program reduced the achievement gaps
  across different racial groups.  Begin by comparing the average
  reading and math test scores between white and minority students
  (i.e., Blacks and hispanics) among those students who were assigned
  to regular classes with no aid.  Conduct the same comparison among
  those students who were assigned to small classes.  
  
  Your output should be four new objects: ``race_gap_read_reg``, ``race_gap_read_small``,
``race_gap_math_reg`` and ``race_gap_math_small``
  
## Answer 4

```{r}
 
```
## Question 4.1
Give a brief
  substantive interpretation of the results of your analysis above.


## Answer 4.1
 
## Question 5

We consider the long term effects of middle school class size.
  Compare high school graduation rates across students assigned to
  different class types.  Also, examine whether graduation rates
  differ by the number of years spent in small classses.  Finally, as
  done in the previous question, investigate whether the STAR program
  has reduced the racial gap between white and minority students'
  graduation rates.  Briefly discuss the results.

## Answer 5

```{r}
 
```

 
## Question 6

Now, let's try a simple matching exercise using this data set. And for this question, we are only interested in comparing classsize **without aid** (the regular and small groups). We will see small size as the **treated** group and regular size as the control group. And we also want to get rid of observations with ``NA" in their values. 

What is the potential problem of getting rid of people with missing values?

Set up a treatment variable where it is TRUE if small class size and FALSE otherwise. For simplicity, change race variable to be an indicator of white = 1, otherwise =0.

 

```{r}
library(MatchIt)
```


## Answer 6
 

## Question 7
Generate an exact matching set using Mahalanobis distance measure for those with a small class size.  Let's ignore ``yearssmall" variable for this task - since it complicates the design by making treatment non-binary.

Calculate the average treatment effect on the treated (small class size) and interpret it. 

## Answer 7
```{r}
 

```



## Question 8

Visualize the matching quality and offer some discussion, on the improvement before and after matching. 

## Answer 8
```{r}
 
```





