View source: R/modified.gtest.R
| modified.gtest | R Documentation |
Performs G-test \insertCiteWOOLF:1957aaUpsilon on contingency tables, slightly modified to handle rows or columns of all zeros.
modified.gtest(x, log.p = FALSE)
x |
a matrix or data frame of floating or integer numbers to specify a contingency table. Entries must be non-negative. |
log.p |
a logical. If |
This test is useful if a p-value must be returned
on a contingency table with valid non-negative counts,
where other implementations of G-test could
return NA as the p-value, regardless of a
pattern being strong or weak.
This function handles tables with empty rows
or columns (where expected values are 0) by
calculating the test statistic over non-zero
entries only. This prevents the result from
becoming NA, while giving meaningful
p-values.
A list with class "htest" containing:
statistic |
the G statistic (log-likelihood ratio). |
parameter |
the degrees of freedom. |
p.value |
the p-value of the test. |
estimate |
the value of mutual information. |
method |
a character string indicating the method used. |
data.name |
a character string, name of the input data. |
observed |
the observed counts. |
expected |
the expected counts under the null hypothesis. |
WOOLF:1957aaUpsilon
library("Upsilon")
# Create a sparse table with empty rows/cols
x <- matrix(
c(0, 3, 0,
3, 0, 0),
nrow = 2, byrow = TRUE
)
print(x)
# Perform the modified G-test
modified.gtest(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.