multinom.test: Test two multinomial datasets

View source: R/multinomial.R

multinom.testR Documentation

Test two multinomial datasets

Description

Peforms a two-sample test for two multinomial vectors testing H_0: the underlying multinomial probability vectors are the same vs. H_1: they are different.

Usage

multinom.test(x, y = NULL)

Arguments

x, y

Integer vectors (or matrices/dataframes containing multiple integer vector observations as rows). x and y must be the same type and dimension. If x and y are matrices (or dataframes), the i^th row of x will be tested against the i^th row of y for all i in 1..nrow(x). Alternatively, x can be a list of two vectors, matrices, or dataframes to be compared. In this case, y is NULL by default.

Value

The statistic and its associated p-value. If x and y are either matrices or dataframes, a statistic and p-value will be returned for each row.

See Also

Amanda Plunkett & Junyong Park (2018) Two-Sample Test for Sparse High Dimensional Multinomial Distributions, TEST, https://doi.org/10.1007/s11749-018-0600-8

Examples

#Generate two vectors from the same distribution:
data <- genMultinomialData(sample_size=1)

#Perform test (the following three calls of multinom.test are equivalent):
multinom.test(x=data[[1]], y=data[[2]])
multinom.test(data)
data |> multinom.test()

#Generate 1000 vectors from each of two different distributions:
data <- genMultinomialData(null_hyp=FALSE,sample_size=1000)

#Perform test (compare the ith row of x to the ith row of y for all rows):
result <- multinom.test(x=data[[1]],y=data[[2]])

#Return power of test at the alpha=0.05 level:
alpha <- 0.05
mean(result$pvalue<alpha)


AmandaRP/hddtest documentation built on March 18, 2023, 5:53 p.m.