Paired nominal data providing the smoking status 62 individuals before and after emotive video communications showing the danger of smoking. This a demo dataset for McNemar test.

It is the data set used in the Datanovia tutorial “McNemar's Test in R: Compare Paired Proportions (Before/After)” (https://www.datanovia.com/learn/biostatistics/categorical/mcnemar-test-in-r).

data("antismoking")

Format

A data frame with 62 rows and 3 columns (stored as a tibble).

id

participant identifier (1 to 62).

before

the smoking status before the communication, "non.smoker" or "smoker".

after

the smoking status after the communication, "non.smoker" or "smoker".

Source

A simulated dataset for teaching McNemar's test.

Examples

data(antismoking)
xtabs(~before + after, data = antismoking)
#>             after
#> before       non.smoker smoker
#>   non.smoker         25      6
#>   smoker             21     10

# McNemar test of the change in smoking status
mcnemar.test(table(antismoking$before, antismoking$after))
#> 
#> 	McNemar's Chi-squared test with continuity correction
#> 
#> data:  table(antismoking$before, antismoking$after)
#> McNemar's chi-squared = 7.2593, df = 1, p-value = 0.007054
#>