In: Statistics and Probability
data
year | state | realbeertax | mwdef | pc_perinc | pop1620 | ur1620_r | ANYBAC26 | NOBAC26 | NOBAC1620 | ANYBAC1620 | |
1998 | 1 | 0.639528 | 6.21428 | 22025 | 330397 | 13.46843 | 260.8 | 402.2 | 117.2 | 42.8 | |
1999 | 1 | 0.630308 | 6.124692 | 22722 | 329695 | 14.9065 | 258.6 | 420.4 | 119.9 | 41.1 | |
2000 | 1 | 0.617784 | 6.002995 | 23767 | 327992 | 16.51312 | 255.5 | 359.5 | 114.4 | 38.6 | |
2001 | 1 | 0.603291 | 5.862171 | 24740 | 321840 | 17.4932 | 222 | 389 | 113.1 | 36.9 | |
2002 | 1 | 0.592925 | 5.761446 | 25461 | 315225 | 16.43963 | 231.4 | 402.6 | 98.7 | 40.3 |
Use R Studio. (you just need to write R code)
year = year state = A code identifying the relevant U.S. state
realbeertax = the state tax per gallon of beer sold pc_perinc =
personal income per person pop1620 = population ages 16-20 ur1620_r
= unemployment rate among people age 16-20 (in percent) ANYBAC26 =
number of fatal accidents involving alcohol among people age 26 and
up ANYBAC1620 = number of fatal accidents involving alcohol among
people age 16-20 NOBAC26 = number of fatal accidents not involving
alcohol among people age 26 and up NOBAC1620 = number of fatal
accidents not involving alcohol among people age 16-20 mwdef =
minimum wage (in 2006 dollars)
1, Create a new variable that is equal to the log of personal
income per person (pc_perinc).
2,Note that this dataset includes observations from all states and from all years between 1998 and 2002. For simplicity, let’s focus on one year: 2001. Create a new object consisting of the data only for 2001
3,We now have a cross-sectional dataset that includes several quantitative variables. One question we might ask is, what is the relationship between (the log of) personal income per capita and a state’s minimum wage? Create a graph that would let you evaluate this relationship visually
4, Use R to calculate the correlation between the two variables you
plotted in question 5.