2
$\begingroup$

I am using the assocstats function in the vcd library. It gives something called the likelihood ratio and its associated p-value which is different from the chi-squared statistic and its p-value. What is this likelihood ratio and what is it's distribution?

e.g.,

> library(vcd)
> data("Arthritis")
> tab <- xtabs(~Improved + Treatment, data = Arthritis)
> assocstats(tab)
                    X^2 df  P(> X^2)
Likelihood Ratio 13.530  2 0.0011536
Pearson          13.055  2 0.0014626

Phi-Coefficient   : NA 
Contingency Coeff.: 0.367 
Cramer's V        : 0.394 
> chisq.test(tab)

    Pearson's Chi-squared test

data:  tab
X-squared = 13.055, df = 2, p-value = 0.001463
$\endgroup$
3
$\begingroup$

A test using that likelihood ratio is generally called G-test. With r×s contingency table, $G = 2 \sum_{i=1}^r \sum_{j=1}^s O_{ij} * ln (O_{ij}/E_{ij}) $. $O_{ij}$ is the observed count and $E_{ij}$ is the expected count under the null hypothesis. Distribution of G is approximately a chi-squared distribution. G-test (wikipedia) gives more information.

observe <- mar_table(tab)[1:3, 1:2]  # delete total
expect <- independence_table(tab)

# (observe) Treatment          (expect) Treatment
# Improved Placebo Treated    Improved   Placebo   Treated
#   None        29      13       None   21.500000 20.500000
#   Some         7       7       Some    7.166667  6.833333
#   Marked       7      21       Marked 14.333333 13.666667

G <- 2 * sum( observe * log(observe/expect) )  # [1] 13.52981
chisq <- sum( (observe - expect)^2/expect )      # [1] 13.05502 # as a reference

1 - pchisq(G, df = 2)             # [1] 0.001153559
1 - pchisq(chisq, df = 2)           # [1] 0.001462643
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.