Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to know what statistics should be used to measure the mixing of languages in cities in a country/state. I have samples from individuals and know the language they speak and the city they live in. The cities are not all the same size and there are 3 different language groups.

The samples are taken uniformly from the total population so that larger cities have a proportionally larger number of samples in the data set.

I want to avoid naive approaches such as; taking the value from A/B since 100/50 is the same as 2/1 and have equal contributions.

share|improve this question
What is the purpose of your study? What would you be using these statistics or measures for? – whuber May 29 '12 at 18:27
@whuber, the purpose is to see if there is segregation or not. If the populations are mixed uniformly or cluster together. – Vass May 29 '12 at 18:28
Your reply indicates your data are richer than just counts of individuals: how otherwise can you discern evidence of segregation within mere counts? Are you perhaps suggesting you want to study how your counts vary geographically? If so, exactly how would such variation be interpreted in terms of "segregation" or lack thereof? To be concrete, suppose the counts are (50K, 10K, 5K) in one city and (0K, 5K, 5K) in another (smaller) city. How do these cities compare in terms of "segregation"? Would your answer change if the third component were a small minority within the state? – whuber May 29 '12 at 18:34
Building on @whuber, and just to check on what you mean by "segregation" - do you actually mean just varying proportions? For example, there is a higher proportion of Spanish speakers in Los Angeles than there is Vancouver, but I don't know that this would mean "segregation" in the common English usage. But this seems to be what you are looking for. Perhaps a better expression would be "varying proportions" of the language groups. – Peter Ellis May 29 '12 at 19:38
@whuber the answer would not change if the third component was a minority within the state although in this example it is. In your example with those numbers the first city is less uniform than the others maybe in terms the distribution of the languages from something merely random. – Vass May 29 '12 at 22:15
up vote 2 down vote accepted

If you are only looking for a score you can take inspiration from the question How does one measure the non-uniformity of a distribution?.

If you have a perfect mixing, the distribution of your languages should be uniform in every city (i.e. 1/3 each language group). If mixing is imperfect, it will not be uniform.

The answer to this post suggests using the $\chi^2$ metric, the entropy or the Kullback-Leibler divergence. I would actually use the last one, which easily allows you to normalize for unequal language distribution in the whole population.

share|improve this answer
I doubt there is any state or country in the world whose population is exactly equally distributed among three languages (or any other three categories, for that matter)! This highlights the importance of looking at the metric in context and of using it to make comparisons rather than on some absolute scale. Of greater concern is the potential for some abstract theoretical answer (no matter how rigorously supported) to be misinterpreted or misused for such a socially important application as assessment of segregation. – whuber May 29 '12 at 19:05
Thanks for the feedback @whuber. If I understand your point, since populations are far from uniform it makes no sense to compare their distance to that ideal situation (+1). Still, as far as I am aware, you can compare the entropies together, without reference to the "absolutely perfect situation". – gui11aume May 29 '12 at 19:56
@gui11aume I am thinking of using the KL divergence… , and using the Beta/Dirichlet distributions for P and Q, and the parameters for P to be the population groups in a region and for Q to be the population group values overall. How does that sound? – Vass May 29 '12 at 22:46
This is what I had in mind when writing the answer. Following the comment of @whuber I admit that comparing your groups to ideal distributions ($Q$ in your case) does not necessarily make sense. Still, you can try, maybe it works just fine. Otherwise you can compute the entropy of the distribution in each city and directly compare those scores. – gui11aume May 30 '12 at 8:18
@gui11aume , I also thought of using absolute differences or some squared deviation, from the average global ratio, what would you think of this? whuber 's comment is correct, but without much more information I cannot take into account all of the necessary contexts to be more accurate. – Vass May 30 '12 at 10:44

A humble Chi sqare test is probably all you need to test the null hypothesis that there is no relationship between mother tongue and city ie that the proportion of speakers is the same in each city (note that this is not the same as all proportions are a third).

As per my comments, I'm not sure this is that useful a question, depending on the context. After all, you would expect different cities to have different proportions of languages wouldn't you, on historical, geographical and cultural grounds? So you will almost certainly reject a null hypothesis of equal proportions.

But the test would be something like the below. The numbers in the table represent the number from a sample reporting that language as their mother tongue (made-up data).

> x <- data.frame(
+ row.names=c("London", "New York", "Hanover"),
+ english=c(100,100,10),
+ german=c(5,8,60),
+ french=c(7,4,12))
> x
         english german french
London       100      5      7
New York     100      8      4
Hanover       10     60     12
> # inbuilt chi square test:
> chisq.test(x)

        Pearson's Chi-squared test

data:  x 
X-squared = 174.4, df = 4, p-value < 2.2e-16

> # or, by hand:
> # First, what are the "expected" values if there 
> # is no relationship between city and language
> e <- apply(x,1,sum) %o% apply(x,2,sum)/sum(x)
> e
         english german french
London     76.86  26.72  8.418
New York   76.86  26.72  8.418
Hanover    56.27  19.56  6.163
> sum((x-e)^2/e)
[1] 174.4
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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