R: Paired Samples Contingency Tables

contTablesPaired {jmv} | R Documentation

## Paired Samples Contingency Tables

### Description

McNemar test

### Usage

    contTablesPaired(data, rows, cols, counts = NULL, chiSq = TRUE,
      chiSqCorr = FALSE, exact = FALSE, pcRow = FALSE, pcCol = FALSE)

### Arguments

`data` | the data as a data frame
`rows` | a string naming the variable to use as the rows in the contingency table
`cols` | a string naming the variable to use as the columns in the contingency table
`counts` | a string naming the variable to use as counts, or NULL if each row represents a single observation
`chiSq` | `TRUE` (default) or `FALSE`, provide X²
`chiSqCorr` | `TRUE` or `FALSE` (default), provide X² with continuity correction
`exact` | `TRUE` or `FALSE` (default), provide an exact log odds ratio
`pcRow` | `TRUE` or `FALSE` (default), provide row percentages
`pcCol` | `TRUE` or `FALSE` (default), provide column percentages

### Value

A results object containing:

`results$freqs` |  |  |  |  | a proportions table
`results$test` |  |  |  |  | a table of test results

Tables can be converted to data frames with `asDF` or `as.data.frame`. For example:

`results$freqs$asDF`

`as.data.frame(results$freqs)`

### Examples

    dat <- data.frame(
        `1st survey` = c('Approve', 'Approve', 'Disapprove', 'Disapprove'),
        `2nd survey` = c('Approve', 'Disapprove', 'Approve', 'Disapprove'),
        `Counts` = c(794, 150, 86, 570),
        check.names=FALSE)

    contTablesPaired(dat, rows = '1st survey', cols = '2nd survey', counts = 'Counts')

    #
    #  PAIRED SAMPLES CONTINGENCY TABLES
    #
    #  Contingency Tables
    #  ------------------------------------------------
    #    1st survey    Approve    Disapprove    Total
    #  ------------------------------------------------
    #    Approve           794           150      944
    #    Disapprove         86           570      656
    #    Total             880           720     1600
    #  ------------------------------------------------
    #
    #
    #  McNemar Test
    #  -----------------------------------------------------
    #                                Value    df    p
    #  -----------------------------------------------------
    #    X²                           17.4     1    < .001
    #    X² continuity correction     16.8     1    < .001
    #  -----------------------------------------------------
    #

[Package jmv version 0.8.6.2 Index]