4

After reading Choropleth Mapping Using Quantile Method in CartoDB I decided that it was time for me to understand CartoDB's quantification methods. As I understand it, quantiles should contain an equal number of rows, equal intervals should place the cutoffs at ... equal intervals, and jenks should do some math and come up with groups that have the smallest standard deviation, more or less. I'm skipping heads/tails for now.

I created a slightly goofball map with 18 points, each with an age value from this list:

[11, 11, 12, 13, 14, 16, 19, 20, 20, 20, 23, 25, 26, 26, 31, 37, 38, 38]

I mapped them and then used the choropleth wizard to look at the implication of the various quantification methods. I expect the Quantile method to break the list into groups of six, which it does:

[11, 11, 12, 13, 14, 16] 
[19, 20, 20, 20, 23, 25]
[26, 26, 31, 37, 38, 38]

I do not expect to see the logic in the Jenks method at a glance, but indeed, the Jenks groups each have a smaller standard deviation than the quantile groupings.

[11, 11, 12, 13, 14, 16, 19] SD = 2.928
[20, 20, 20, 23, 25, 26, 26] SD = 2.854
[31, 37, 38, 38] SD = 3.367

The SD for the quantile groups is 1.9, 2.3, 5.8 (At least per Calc's =STDEV function.)

So far so good. When I select Equal Intervals I was expecting cutoffs 8 or 9 years apart (so 19 and 28 or 20 and 30 but the CSS places the cutoffs exactly where the quantile cutoffs were, giving groups that are 5, 8, and 12 years long -- not very equal:

#interval_new [ age <= 38] {
   marker-fill: #F03B20;
}
#interval_new [ age <= 25] {
   marker-fill: #FEB24C;
}
#interval_new [ age <= 16] {
   marker-fill: #FFEDA0;
}

Am I misunderstanding how equal intervals work? Or is this a bug?

  • 1
    I don't know cartoDB, but your interpretation of equal interval is correct : it should be 11-20/20-29/29-38 – radouxju Jan 28 '14 at 19:07
  • yep, that looks like a bug! good catch :) – andrewxhill Jan 28 '14 at 19:22
  • if you are ever in the mood, I implemented the Jenks algo and would love a second look, github.com/CartoDB/cartodb/blob/master/lib/sql/… the goal is to decrease SD in each group while maximizing it across – andrewxhill Jan 28 '14 at 19:24
  • Just for comparison sake, I used your same values in ArcGIS and came up with Equal Intervals of 11-20, 21-29, 30-38. Jenks was similar to CartoDB implementation but not quite the same at 11-16, 17-26, 27-38. – RyanDalton Jan 28 '14 at 19:24
  • 1
    @andrewxhill, please move your comments to an answer so that Amanda can accept and close out this question. Thanks! – RyanDalton Jan 28 '14 at 23:55
0

Our tests confirm that the Equal Interval method in CartoDB currently implements the Quantile method.

We ran a few more tests to try to determine what the Quantile method in CartoDB actually implements. We realized that the Quantile method produces some weird outputs when there are repeated values. Amanda's example above indicates that the Quantile method is implementing the Equal Interval method, but we found errors if there are repeated values in data. For example, we modified Amanda's original input given above to introduce 3 more 11's to the data as below and resulting buckets for both methods as follows:

Values: [38,39,37,31,26,26,25,23,20,20,20,19,16,14,13,12,11,11,11,11,11]

Equal Interval Ouput from CartoDB:

<=38 [38,38,37,31,26,26,25]

<=23 [23,20,20,20,19,16,14]

<=13 [13,12,11,11,11,11,11]

Quantile Output from CartoDB:

<=38 [38,38,37,31,26,26]

<=25 [25,23,20,20,20,19]

<=16 [16,14,13,12,11,11,11,11,11]

So based on this output we theorized, that indeed Equal Interval method is producing Quantiles even with repeated values, but, Quantile Method is applying original Quantile Algorithm on only the unique value in the data, ignoring repeating values. Here's how we think the Quantile output above is produced:

Quantile Output from CartoDB (with unique values only):

<=38 [38,37,31,26]

<=25 [25,23,20,19]

<=16 [16,14,13,12,11]

In order to test this we introduced additional repeating values (specifically 3 more 16's) and the Quantile output gave the same breaks as above, where it should have shifted the boundaries of buckets.

Values: [38,39,37,31,26,26,25,23,20,20,20,19,16,16,16,16,14,13,12,11,11,11,11,11]

Quantile Output from CartoDB:

<=38 [38,38,37,31,26,26]

<=25 [25,23,20,20,20,20,19]

<=16 [16,16,16,16,14,13,12,11,11,11,11,11]

Andrew, can you confirm if CartoDB Quantile output is behaving as we suspect it?

Amanda, thanks for picking up this thread - it has helped us answer our question in a previous question: Choropleth Mapping Using Quantile Method in CartoDB

  • I think the answer for gis.stackexchange.com purposes is ... "yes: tis a bug" -- the rest can happen on Github issues. – Amanda Jan 29 '14 at 22:04

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.