# How to test normalized frequencies

I have extracted the frequency of two words (can, may) from two corpora (Corpus1, Corpus2).

I want to test if there is a significant difference between the counts in the two corpora, but since the corpora are of different different sizes I have to normalized these counts (for instance to occurrence per 1000 words).

Any ideas for how I can do this in R? And what statistical test would you recommend?

• "What statistical test..." is an on-topic question here, but "how can I do it in R" is not. Be aware that you may not get answers for the latter. – gung Feb 28 at 12:21

## 1 Answer

In statistical terms, your question is about a test for the difference in probability for two binomial random variables with different population sizes. I.e. we have that number of occurrences of a word in the corpora are distributed $$X_1 \sim \text{Binomial}(n_1, p_1),$$ and $$X_2\sim\text{Binomial}(n_2, p_2),$$ and we want to test the hypothesis $$H_0: p_1 = p_2.$$ In this setting, I would recommend using the function prop.test(), which computes the test you want if you give it the data in the form a vector of occurrences $$(x_1, x_2)$$ and a vector of corpus lengths $$(n_1, n_2).$$ I.e. If there are 400 words in the first corpus, with 20 occurrences of "can", and 700 words in the second corpus with 60 occurrences of "can", then executing the line

prop.test(x=c(20, 60), n=(400, 700))

will compute the test (p-values, confidence interval for $$p_1 - p_2$$, etc) for the difference.