| fast.gtest | R Documentation |
Performs a fast zero-tolerant G-test \insertCiteWOOLF:1957aaUpsilon to evaluate association between observations from two categorical variables.
fast.gtest(x, y, log.p = FALSE)
x |
a vector to
specify observations of the first
categorical variable. The vector can be of
numeric, character, or logical type.
|
y |
a vector to specify observations of
the second categorical variable.
Must not contain |
log.p |
a logical. If |
A list with class "htest" containing the following components:
statistic |
the G-test statistic (Likelihood Ratio Chi-squared statistic). |
parameter |
the degrees of freedom. |
p.value |
the p-value of the test. |
estimate |
the mutual information between the two variables. |
method |
a character string indicating the method used. |
data.name |
a character string giving the names of the data. |
The test uses an internal hash table, instead of matrix, to store the contingency table. Savings in both runtime and memory saving can be substantial if the contingency table is sparse and large. The test is implemented in C++, to give an additional layer of speedup over an R implementation.
WOOLF:1957aaUpsilon
library("Upsilon")
weather <- c(
"rainy", "sunny", "rainy", "sunny", "rainy"
)
mood <- c(
"wistful", "upbeat", "upbeat", "upbeat", "wistful"
)
fast.gtest(weather, mood)
# The result is equivalent to:
modified.gtest(table(weather, mood))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.