xtp.chi2: Cross tabulation Analysis with Chi-Squared Statistic

Description Usage Arguments Value Examples

View source: R/xtp.chi2.r

Description

This function makes use of the crosstab function from the descr package

Usage

1
xtp.chi2(data, y, x, w = NULL, digits = 1, prop.c = FALSE)

Arguments

data

Dataset to be sorted

y

Dependent variable

x

Independent variable

w

Weights (optional)

digits

Number of digits to report after decimal place, optional (default = 1).

prop.c

Do you want column percentages reported in table? (default is FALSE)

Value

Returns a data frame of cross tabulation results

Examples

1
2
3
   library(poliscidata)
   
   xtp.chi2(gss, pornlaw, attend3, wtss)

Example output

   Cell Contents 
|-------------------------|
|                   Count | 
|         Expected Values | 
|-------------------------|

====================================================
                    attend3
pornlaw               Low   Moderate    High   Total
----------------------------------------------------
ILLEGAL TO ALL        113         82     233     428
                    185.3      113.5   129.2        
----------------------------------------------------
ILLEGAL UNDER 18      428        257     156     841
                    364.1      223.1   253.8        
----------------------------------------------------
LEGAL                  27          9       7      43
                     18.6       11.4    13.0        
----------------------------------------------------
Total                 568        348     396    1312
====================================================

Statistics for All Table Factors

Pearson's Chi-squared test 
------------------------------------------------------------
Chi^2 = 181.5177      d.f. = 4      p <2e-16 

        Minimum expected frequency: 11.40549 

poliscidata documentation built on July 8, 2020, 6:23 p.m.