# Converting a continuous variable to categorical

I have several continuous predictor variables and one binary outcome variable. One of these predictor variables has the following description using the Hmisc package:

> describe(dfhh$$x1) dfhh$$x1
n  missing distinct     Info     Mean      Gmd      .05      .10      .25      .50      .75      .90      .95
7888        0     4863        1    41.67    19.79    20.26    23.22    29.14    37.14    48.57    63.61    77.40

lowest :   0.000   8.246   8.797   9.616   9.841, highest: 248.542 250.113 283.178 338.605 354.072


I want to get some descriptive statistics out of this, such as an odds ratio to see what happens at one level relative to another. I felt that dichotomatizing this variable would aid in the objective at hand, but I'm not quite sure how to go about it.

• There's no set way to divide a continuous variable into categories. Sometimes there is a logical cutoff. For example, if you have a drinking water quality standard, you can classify observations as to whether they met this criterion or not. Otherwise, you might divide a variable into quantiles or other groups of equal observations. The cut2 function in Hmisc is a convenient way to do this. – Sal Mangiafico Aug 21 '17 at 17:23
• @SalMangiafico so in the absence of a logical cutoff, just cutting into equal bins would be acceptable? – Jonathan Rauscher Aug 21 '17 at 17:40
• I think it really depends on the data and your purpose in categorizing it. If categorizing into two groups, does it make sense to divide data into greater than or less than the median? If into five groups, does it make sense to break into quantiles? – Sal Mangiafico Aug 21 '17 at 17:47
• The purpose would be to garner descriptive statistics and quantify the effects between levels of a given variable. – Jonathan Rauscher Aug 21 '17 at 18:10
• Right. But a continuous variable doesn't have inherent "levels". It only has the levels you assign to it if you have cause to do so. So, there's no general formula here. If it makes sense to break the variable into two, or into five, or into 10 categories, you can. But in general, leaving it as a continuous variable preserves more information, and so is usually advantageous. (Cont.) – Sal Mangiafico Aug 21 '17 at 18:18