chisq.detail: Print details of a chi-squared test

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Prints out the details of the computations involved in a chi-squared test on a table. Includes the expected values and the chi-squared contribution of each cell.

Usage

1

Arguments

tab

Matrix or table to be analyzed

Details

This function prints out the input table along with the expected value for each cell under the null hypothesis. It also prints out the chi-squared contribution of each cell in the same pattern as the table. This shows the computations involved and one rule of thumb is to look for these values that are greater than 4 as a post-hoc analysis.

Value

This function is used primarily for its side effect of printing the results, but does return invisibly a list with the following components:

obs

A matrix of the observed values, same as tab.

expected

A matrix of the expected values under the null hypothesis.

chi.table

A matrix of the chi-squared contributions of each cell.

chi2

The chi-squared test statistic.

Author(s)

Greg Snow, 538280@gmail.com

References

~put references to the literature/web site here ~ Moore, bps

See Also

chisq.test,loglin, xtabs, table, prop.table, CrossTable from the gmodels package.

Examples

1
2

Example output

observed
expected

      Brown   Blue Hazel Green Total
Black 32     11    10     3       56
      19.67  20.27  9.43  6.62      
                                    
Brown 53     50    25    15      143
      50.23  51.77 24.09 16.91      
                                    
Red   10     10     7     7       34
      11.94  12.31  5.73  4.02      
                                    
Blond  3     30     5     8       46
      16.16  16.65  7.75  5.44      
                                    
Total 98    101    47    33      279


Cell Contributions
      Brown    Blue   Hazel   Green        
Black  7.73 +  4.24 +  0.03 +  1.98 +      
Brown  0.15 +  0.06 +  0.03 +  0.22 +      
Red    0.32 +  0.43 +  0.28 +  2.21 +      
Blond 10.71 + 10.70 +  0.98 +  1.20 = 41.28

df = 9  P-value = 0 



observed
expected

       Brown   Blue Hazel Green Total
Black  36      9     5     2       52
       20.27  18.94  7.64  5.15      
                                     
Brown  66     34    29    14      143
       55.74  52.08 21.02 14.16      
                                     
Red    16      7     7     7       37
       14.42  13.48  5.44  3.66      
                                     
Blond   4     64     5     8       81
       31.57  29.50 11.90  8.02      
                                     
Total 122    114    46    31      313


Cell Contributions
      Brown    Blue   Hazel   Green         
Black 12.21 +  5.22 +  0.91 +  1.93 +       
Brown  1.89 +  6.28 +  3.03 +  0.00 +       
Red    0.17 +  3.11 +  0.45 +  3.04 +       
Blond 24.08 + 40.34 +  4.00 +  0.00 = 106.66

df = 9  P-value = 0 

TeachingDemos documentation built on April 2, 2020, 3:01 a.m.