How to dynamically calculate interval designations of data? I am looking for an equation to calculate appropriate intervals to designate values as very low, low, medium, high, very high for dynamic data.
for example if my dataset ranges from 0 to 100 very low= <=20, low=21-40, medium=41-60, high=61-80, very high= >81
However, if the range is small there should be fewer intervals. For example, if the range is 20 then there should be a low and high interval designation only.
the intervals need to be logical intervals so they can be used for a graphical display. logical intervals would include intervals of 5, 10, 25, 50, 100 etc depending on the dataset. Is there an equation that can determine appropriate intervals for each unique dataset?
 A: A few quick thoughts:


*

*Your example makes it sound like you have a specific application in mind, such that you could program the cut points as a set of if-then rules. E.g., if max = 20, then cutpoint is 10; if max = 50 then cutpoints are 15, 30, 45; etc...

*You could have a look at the cut function in R to get additional ideas.

*The literature on histograms, bin size, etc (e.g., see wikipedia) may also be relevant.


You probably want to think about what properties are most desirable:


*

*Importance of rounding to 5s, 10s, 100s on interval borders

*Equality of intervals versus equality of proportion of sample in each interval

*The functional relationship between range and number of intervals that you want to use

A: Dividing any range into intervals is subjective. What makes '20' a small range and '100' a big range? What about a range of 1? Or 1000000?
However, if you can think of a few more hypothetical scenarios such as the two you provided (20 range->2 intervals, 100 range->5 intervals), you can fit a function to them that will tell you how many intervals to keep. For instance, if you graph 20,2 and 100,5 and fit a linear function you'll get:
$y=0.375x+1.25$
or a logarithmic function would give you:
$y=1.864ln(x)-3.5841$
where x is your range and y is the number of intervals you should keep. Of course, these functions would be a lot more meaningful if you had more than 2 a priori examples. In that case, you would choose the function that fits best (the highest $R^2$).
After determining the number of intervals you should keep, you can simply space the intervals evenly throughout your data, or round to the nearest "logical interval".
As Jeromy suggests, there are several other factors you may want to keep in mind besides this functional relationship, so YMMV-- but it's a start.
