Keyness and log-likelihood calculator
Enter a word's frequency and the size of each corpus to test whether it is significantly more frequent in one, and how large the difference is.
Enter the frequencies
Use raw counts and the total number of tokens (words) in each corpus.
LIVE RESULT
INSTANTKeyness of the word
Log-likelihood is calculated over the two observed frequencies, as in Rayson and Garside (2000) and the Lancaster log-likelihood wizard. Zero frequencies are set to 0.5 for Log Ratio only.
What keyness measures
Keyness asks whether a word occurs unusually often (or rarely) in one corpus compared with another, more than chance variation would explain. Corpus linguists use it to find the words that characterise a body of text, such as a set of political speeches compared with general news. Because the corpora differ in size, raw counts cannot be compared directly; the test compares observed frequencies with those expected if the word were equally common in both.
E₁ = c × (a + b) ÷ (c + d), E₂ = d × (a + b) ÷ (c + d)
LL = 2 × (a ln(a ÷ E₁) + b ln(b ÷ E₂))
where a and b are the word's frequencies, and c and d the corpus sizes
LL follows a chi-square distribution with one degree of freedom. The usual critical values are 3.84 (p < .05), 6.63 (p < .01), 10.83 (p < .001) and 15.13 (p < .0001). When many words are tested at once, use the stricter values or a correction for multiple testing.
Worked example
A word occurs 120 times in a 1,000,000-word corpus and 40 times in an 800,000-word reference corpus: 120 versus 50 per million words. Expected frequencies are 88.9 and 71.1, giving LL = 26.00 (p < .0001). The word is 140% more frequent in corpus 1, a Log Ratio of 1.26.
Significance is not size
LL grows with corpus size, so in large corpora even trivial differences become significant. The same relative difference in corpora a tenth of the size (12 versus 4 occurrences) gives LL = 2.60 (not significant), while the effect size stays the same: %DIFF 140%, Log Ratio 1.26. That is why current practice is to report an effect size alongside LL and to rank keywords by effect size, using LL as a filter.
| Effect size | Meaning | Source |
|---|---|---|
| %DIFF | Percentage difference between the normalised frequencies | Gabrielatos and Marchi (2012) |
| Log Ratio | Binary log of the ratio of relative frequencies: each +1 doubles the frequency | Hardie (2014) |
| Bayes factor (BIC) | LL − ln N. Above 2 positive, above 6 strong, above 10 very strong evidence | Wilson (2013) |
| ELL | Effect size for log-likelihood, from 0 upwards | Johnston et al. (2006) |
Good practice
- Use a reference corpus of similar size or larger, and of a genre that makes the comparison meaningful.
- Check dispersion: a word can be key only because one text in the corpus uses it heavily.
- Report the software, the corpus sizes in tokens, the threshold and the effect size used.
Coding texts into categories rather than counting words? Check your coders' agreement with the inter-coder reliability calculator.
The same 2-cell G² log-likelihood test also works as a general contingency G-test whenever you compare one observed event count against two total trial counts.
Common questions
Frequently asked questions
What is the difference between log-likelihood (G²) and chi-square?
Both compare observed and expected counts under a chi-square distribution with 1 degree of freedom, but the G-test (log-likelihood) handles skewed or rare-event frequencies more reliably than Pearson chi-square without Yates correction.
Can I use this log-likelihood calculator outside corpus linguistics?
Yes. Enter any two observed event counts and their corresponding total sample or exposure sizes to compute G², its exact p-value, relative difference and Bayes factor.
Why report Log Ratio or %DIFF alongside log-likelihood?
Log-likelihood measures statistical evidence against equal rates and grows with sample size, whereas Log Ratio and %DIFF measure how large the relative difference actually is.