November 12, 2015

Hello

##    PUBID_1997      Sex_1997       Race_1997     Marstatus_2013  
##  Min.   :   1   Min.   :1.000   Min.   :1.000   Min.   :0.0000  
##  1st Qu.:2249   1st Qu.:1.000   1st Qu.:1.000   1st Qu.:0.0000  
##  Median :4502   Median :1.000   Median :4.000   Median :1.0000  
##  Mean   :4504   Mean   :1.488   Mean   :2.788   Mean   :0.6816  
##  3rd Qu.:6758   3rd Qu.:2.000   3rd Qu.:4.000   3rd Qu.:1.0000  
##  Max.   :9022   Max.   :2.000   Max.   :4.000   Max.   :4.0000  
##                                                 NA's   :1864

## Loading required package: dplyr
## 
## Attaching package: 'dplyr'
## 
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## 
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
## 
## Loading required package: magrittr
## Loading required package: ggvis
## Observations: 8,984
## Variables: 4
## $ PUBID_1997     (int) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ...
## $ Sex_1997       (int) 2, 1, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1,...
## $ Race_1997      (int) 4, 2, 2, 2, 2, 2, 2, 4, 4, 4, 2, 2, 2, 2, 2, 2,...
## $ Marstatus_2013 (int) 0, 0, 0, 0, 1, 1, NA, NA, 0, NA, 0, 0, 0, NA, N...
##    PUBID_1997      Sex_1997       Race_1997     Marstatus_2013  
##  Min.   :   1   Min.   :1.000   Min.   :1.000   Min.   :0.0000  
##  1st Qu.:2249   1st Qu.:1.000   1st Qu.:1.000   1st Qu.:0.0000  
##  Median :4502   Median :1.000   Median :4.000   Median :1.0000  
##  Mean   :4504   Mean   :1.488   Mean   :2.788   Mean   :0.6816  
##  3rd Qu.:6758   3rd Qu.:2.000   3rd Qu.:4.000   3rd Qu.:1.0000  
##  Max.   :9022   Max.   :2.000   Max.   :4.000   Max.   :4.0000  
##                                                 NA's   :1864

Filter for missing data

##    PUBID_1997      Sex_1997       Race_1997     Marstatus_2013  
##  Min.   :   1   Min.   :1.000   Min.   :1.000   Min.   :0.0000  
##  1st Qu.:2350   1st Qu.:1.000   1st Qu.:1.000   1st Qu.:0.0000  
##  Median :4624   Median :2.000   Median :4.000   Median :1.0000  
##  Mean   :4589   Mean   :1.504   Mean   :2.735   Mean   :0.6816  
##  3rd Qu.:6848   3rd Qu.:2.000   3rd Qu.:4.000   3rd Qu.:1.0000  
##  Max.   :9022   Max.   :2.000   Max.   :4.000   Max.   :4.0000

Test the statistical null hypothesis that the three variables are independent.

## , , mar_st2013$Marstatus_2013 = 0
## 
##                    mar_st2013$Race_1997
## mar_st2013$Sex_1997   1   2   3   4
##                   1 628 409  19 841
##                   2 715 329  15 569
## 
## , , mar_st2013$Marstatus_2013 = 1
## 
##                    mar_st2013$Race_1997
## mar_st2013$Sex_1997   1   2   3   4
##                   1 251 280  10 823
##                   2 228 350  14 976
## 
## , , mar_st2013$Marstatus_2013 = 2
## 
##                    mar_st2013$Race_1997
## mar_st2013$Sex_1997   1   2   3   4
##                   1   5  11   2  11
##                   2  15  11   0  29
## 
## , , mar_st2013$Marstatus_2013 = 3
## 
##                    mar_st2013$Race_1997
## mar_st2013$Sex_1997   1   2   3   4
##                   1  47  54   3 136
##                   2  69  78   4 172
## 
## , , mar_st2013$Marstatus_2013 = 4
## 
##                    mar_st2013$Race_1997
## mar_st2013$Sex_1997   1   2   3   4
##                   1   2   1   0   1
##                   2   2   3   0   7
##                                          mar_st2013$Marstatus_2013   0   1   2   3   4
## mar_st2013$Sex_1997 mar_st2013$Race_1997                                              
## 1                   1                                              628 251   5  47   2
##                     2                                              409 280  11  54   1
##                     3                                               19  10   2   3   0
##                     4                                              841 823  11 136   1
## 2                   1                                              715 228  15  69   2
##                     2                                              329 350  11  78   3
##                     3                                               15  14   0   4   0
##                     4                                              569 976  29 172   7
## Call: xtabs(formula = ~mar_st2013$Sex_1997 + mar_st2013$Race_1997 + 
##     mar_st2013$Marstatus_2013)
## Number of cases in table: 7120 
## Number of factors: 3 
## Test for independence of all factors:
##  Chisq = 557.3, df = 31, p-value = 8.601e-98
##  Chi-squared approximation may be incorrect

Chisq = 557.3, df = 31, p-value = 8.601e-98, depends on the P value we reject the null hypothesis which means that these variables are depended

APA table displays the crosstabulation of the variables