Learn R Programming

rstatix (version 0.7.2)

multinom_test: Exact Multinomial Test

Description

Performs an exact multinomial test. Alternative to the chi-square test of goodness-of-fit-test when the sample size is small.

Usage

multinom_test(x, p = rep(1/length(x), length(x)), detailed = FALSE)

Value

return a data frame containing the p-value and its significance.

The returned object has an attribute called args, which is a list holding the test arguments.

Arguments

x

numeric vector containing the counts.

p

a vector of probabilities of success. The length of p must be the same as the number of groups specified by x, and its elements must be greater than 0 and less than 1.

detailed

logical value. Default is FALSE. If TRUE, a detailed result is shown.

See Also

binom_test

Examples

Run this code
# Data
tulip <- c(red = 81, yellow = 50, white = 27)

# Question 1: are the color equally common ?
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# this is a test of homogeneity
res <- multinom_test(tulip)
res

attr(res, "descriptives")

# Pairwise comparisons between groups
pairwise_binom_test(tulip, p.adjust.method = "bonferroni")


# Question 2: comparing observed to expected proportions
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# this is a goodness-of-fit test
expected.p <- c(red = 0.5, yellow = 0.33, white = 0.17)
res <- multinom_test(tulip, expected.p)
res
attr(res, "descriptives")

# Pairwise comparisons against a given probabilities
pairwise_binom_test_against_p(tulip, expected.p)

Run the code above in your browser using DataLab