## Source: local data frame [50 x 7]
## 
##     stateNames Population Income Illiteracy LifeExp Murder HSGrad
##         (fctr)      (int)  (int)      (dbl)   (dbl)  (dbl)  (dbl)
## 1      Alabama       3615   3624        2.1   69.05   15.1   41.3
## 2       Alaska        365   6315        1.5   69.31   11.3   66.7
## 3      Arizona       2212   4530        1.8   70.55    7.8   58.1
## 4     Arkansas       2110   3378        1.9   70.66   10.1   39.9
## 5   California      21198   5114        1.1   71.71   10.3   62.6
## 6     Colorado       2541   4884        0.7   72.06    6.8   63.9
## 7  Connecticut       3100   5348        1.1   72.48    3.1   56.0
## 8     Delaware        579   4809        0.9   70.06    6.2   54.6
## 9      Florida       8277   4815        1.3   70.66   10.7   52.6
## 10     Georgia       4931   4091        2.0   68.54   13.9   40.6
## ..         ...        ...    ...        ...     ...    ...    ...

1. Compute and report correlations among these six variables and plot a correlogram representing these correlations.

## $r
##            LifeExp Income HSGrad Population Illiteracy Murder
## LifeExp          1                                           
## Income        0.34      1                                    
## HSGrad        0.58   0.62      1                             
## Population  -0.068   0.21 -0.098          1                  
## Illiteracy   -0.59  -0.44  -0.66       0.11          1       
## Murder       -0.78  -0.23  -0.49       0.34        0.7      1
## 
## $p
##            LifeExp  Income  HSGrad Population Illiteracy Murder
## LifeExp          0                                             
## Income       0.016       0                                     
## HSGrad     9.2e-06 1.6e-06       0                             
## Population    0.64    0.15     0.5          0                  
## Illiteracy   7e-06  0.0015 2.2e-07       0.46          0       
## Murder     2.3e-11    0.11 0.00032      0.015    1.3e-08      0
## 
## $sym
##            LifeExp Income HSGrad Population Illiteracy Murder
## LifeExp    1                                                 
## Income     .       1                                         
## HSGrad     .       ,      1                                  
## Population                       1                           
## Illiteracy .       .      ,                 1                
## Murder     ,              .      .          ,          1     
## attr(,"legend")
## [1] 0 ' ' 0.3 '.' 0.6 ',' 0.8 '+' 0.9 '*' 0.95 'B' 1

2. Using ggvis, construct

a. plots that demonstrate the relationship between

i. HSGrad and Income,

and

ii. Illiteracy and Income.

b. A scatterplot of Murder by Illiteracy grouped by HSGrad.

3. Report tests of null hypotheses that

a. there is no difference in Income between states above median HSGrad and states less than or equal to median HSGrad,

## Source: local data frame [50 x 7]
## 
##    Population Income Illiteracy LifeExp Murder HSGrad median
##         (int)  (int)      (dbl)   (dbl)  (dbl)  (dbl)  (dbl)
## 1        3615   3624        2.1   69.05   15.1   41.3      0
## 2         365   6315        1.5   69.31   11.3   66.7      1
## 3        2212   4530        1.8   70.55    7.8   58.1      1
## 4        2110   3378        1.9   70.66   10.1   39.9      0
## 5       21198   5114        1.1   71.71   10.3   62.6      1
## 6        2541   4884        0.7   72.06    6.8   63.9      1
## 7        3100   5348        1.1   72.48    3.1   56.0      1
## 8         579   4809        0.9   70.06    6.2   54.6      1
## 9        8277   4815        1.3   70.66   10.7   52.6      1
## 10       4931   4091        2.0   68.54   13.9   40.6      0
## ..        ...    ...        ...     ...    ...    ...    ...
## 
##  Welch Two Sample t-test
## 
## data:  StateIndicator2$Income by StateIndicator2$median
## t = -9.0052, df = 47.995, p-value = 6.973e-12
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -1179.5304  -748.9496
## sample estimates:
## mean in group 0 mean in group 1 
##         3953.68         4917.92

According to the t-test, the p-value= 6.973e-12 which is < α = .05, so reject the null hypotheses. So, there is statically difference in Income between states above median HSGrad and states less than or equal to median HSGrad, t = -9.0052, df = 47.995, p-value = 6.973e-12, 95% CI, [-1179.5304, -748.9496]

and

b. there is no difference in Murder between one group of states (to include Alabama, Alaska, Arkansas, Georgia, Illinois, Kentucky, Louisiana, Mississippi, and Michigan) and another group of states (Arizona, Connecticut, Iowa, Kansas, Maine, Minnesota, Nebraska, New Hampshire, North Dakota)

## Observations: 50
## Variables: 8
## $ Population      (int) 3615, 365, 2212, 2110, 21198, 2541, 3100, 579,...
## $ Income          (int) 3624, 6315, 4530, 3378, 5114, 4884, 5348, 4809...
## $ Illiteracy      (dbl) 2.1, 1.5, 1.8, 1.9, 1.1, 0.7, 1.1, 0.9, 1.3, 2...
## $ LifeExp         (dbl) 69.05, 69.31, 70.55, 70.66, 71.71, 72.06, 72.4...
## $ Murder          (dbl) 15.1, 11.3, 7.8, 10.1, 10.3, 6.8, 3.1, 6.2, 10...
## $ HSGrad          (dbl) 41.3, 66.7, 58.1, 39.9, 62.6, 63.9, 56.0, 54.6...
## $ median          (dbl) 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1...
## $ StateIndicator3 (fctr) 1, 1, 0, 1, California, Colorado, 0, Delaware...
## Source: local data frame [18 x 8]
## 
##    Population Income Illiteracy LifeExp Murder HSGrad median
##         (int)  (int)      (dbl)   (dbl)  (dbl)  (dbl)  (dbl)
## 1        3615   3624        2.1   69.05   15.1   41.3      0
## 2         365   6315        1.5   69.31   11.3   66.7      1
## 3        2212   4530        1.8   70.55    7.8   58.1      1
## 4        2110   3378        1.9   70.66   10.1   39.9      0
## 5        3100   5348        1.1   72.48    3.1   56.0      1
## 6        4931   4091        2.0   68.54   13.9   40.6      0
## 7       11197   5107        0.9   70.14   10.3   52.6      1
## 8        2861   4628        0.5   72.56    2.3   59.0      1
## 9        2280   4669        0.6   72.58    4.5   59.9      1
## 10       3387   3712        1.6   70.10   10.6   38.5      0
## 11       3806   3545        2.8   68.76   13.2   42.2      0
## 12       1058   3694        0.7   70.39    2.7   54.7      0
## 13       9111   4751        0.9   70.63   11.1   52.8      1
## 14       3921   4675        0.6   72.96    2.3   57.6      1
## 15       2341   3098        2.4   68.09   12.5   41.0      0
## 16       1544   4508        0.6   72.60    2.9   59.3      0
## 17        812   4281        0.7   71.23    3.3   57.6      0
## 18        637   5087        0.8   72.78    1.4   50.3      1
## Variables not shown: StateIndicator3 (fctr)
## 
##  Welch Two Sample t-test
## 
## data:  sub3$Murder by sub3$StateIndicator3
## t = -10.124, df = 15.943, p-value = 2.393e-08
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -10.454997  -6.833892
## sample estimates:
## mean in group 0 mean in group 1 
##        3.366667       12.011111

According to the t-test, the p-value = 2.393e-08 which is < α = .05, so reject the null hypotheses. So, there is a statically difference in Murder between the selected two groups of states, t = -10.124, df = 15.943, p-value = 2.393e-08, 95% CI, [-10.454997, -6.833892]