ggchisqtest: Plot for Pearson's Chi-squared Test for Count Data

View source: R/ggchisqtest.R

ggchisqtestR Documentation

Plot for Pearson's Chi-squared Test for Count Data

Description

Visualise chi-squared contingency table tests and goodness-of-fit tests.

Usage

ggchisqtest(t, colaccept="lightsteelblue1", colreject="gray84",
colstat="navyblue", alpha=0.05)

Arguments

t

a list result of chisq.test of "htest" class

colaccept

color the acceptance area of the test

colreject

color for the rejection area of the test

colstat

color for the test statistic vline

alpha

default set to 0.05, choose confidence level for the plot as it is not stated in chisqtest

Examples

## Chi-squared test for given probabilities

x <- c(A = 20, B = 15, C = 25)
chisq_test <- chisq.test(x)
chisq_test
ggchisqtest(chisq_test)


x <- c(10, 86, 45, 38, 10)
p <- c(0.10, 0.40, 0.20, 0.20, 0.10)
chisq_test2 <- chisq.test(x, p = p)
chisq_test2
ggchisqtest(chisq_test2)



## Pearson's Chi-squared test

library(MASS)
sex_smoke <- table(survey$Sex, survey$Smoke)
chisq_test3 <- chisq.test(sex_smoke)
chisq_test3
ggchisqtest(chisq_test3)

okgreece/gginference documentation built on July 6, 2023, 10:02 a.m.