# Should I turn a distinct quantitative feature into a dummy variable?

I am attempting to run a logistic regression on a data set. Within this regression, I have a feature that is quantitative in nature, but only contains a definite set of values (three). For example, I have a feature x that contains values 15,20,30 Should I create new dummy variable for each value of the set, effectively turning the measure into a dimension? Or should I keep the feature as a measure, even though it is not continuous?

There are two major considerations at play here: does the data support a linear relationship between $y$ and $X$, and does the number of data points of each type support estimating parameters for each category.

On the first point, it's only reasonable to fit a line through your data if you can reasonably expect that the conditional means of $y$ are linearly related to $x$:

$$E[y \mid x] = \beta_0 + \beta_1 x \ \text{?}$$

This can be supported either though subject matter knowledge, a scientific model of the relationship, or gumshoe exploratory data analysis.

On the second point, it only makes sense to estimate a different parameter for each category if there is enough data to do so. As an absurd example, if there are 100 datapoints with $x = 15$, 100 datapoints with $x = 20$, but then only one with $x = 25$, estimating a parameter for $x = 25$ would be foolish (in this case it would be better to fit the line, and assume a linear extension). This can be understood through bias and variance, you need to reduce the bias of the model enough to compensate for the increased variance of estimating two more parameters.

• Assuming there is enough data to estimate dummy effects, it seems to be a good idea to start with a model including dummy variables to check whether the linearity assumption is verified. Then there are plenty "intermediate" options between dummy and linear specification. For example you could add a quadratic term or consider splines regression. Commented Jun 14, 2017 at 21:21

No right or wrong answer, it depends on the relationship with the dependent variable. Try it both ways and see.

• Not only does he only need two, he needs to use fewer than three. Commented Jun 14, 2017 at 3:42
• Can you go more into depth on the relationship with the dependent variable portion of the anwser? Commented Jun 14, 2017 at 3:45
• (-1) The downvote is for "My Guess", what is supporting this guess? The answer doesn't really attempt to explain or analyse the situation. Commented Jun 14, 2017 at 4:03