# Including a quadratic effect for an ordinal variable in a regression analysis

It's common for many datasets to have ordinal versions of numerical variables, such as age groups (e.g. "Under 20", "20-30", "30-40", etc.) or time groups (e.g. "Less than 15 minutes", "15-30 minutes", "30-60 minutes", etc.).

Sometimes the continuous versions of these variables are suspected to have a curvilinear relationship with the outcome variable (e.g. age is positively association with income until retirement age and then has a negative trend).

In such cases when these variables are continuous, I would simply create a new squared version of it and include both terms in the model (e.g. regressing income on age and age2).

Is this still okay to do with ordinal variables? Using the time group variable above, it would look like this:

 Original Var. Label | Original Var. Coding | Squared Var. Coding
------------------------------------------------------------------
15 minutes or less   | 1                    | 1
15-30 minutes        | 2                    | 4
30-60 minutes        | 3                    | 9
1-2 hours            | 4                    | 16
2 hours or more      | 5                    | 25


Would this be okay in a regression analysis? If no, what are the alternatives? If so, are there any caveats?

## 1 Answer

If you are entering the categorical variable as a set of binary dummies, you are already allowing the relationship to have a very flexible form that should pick up the quadratic non-linearity that you are worried about. It will even pick more complicated patterns as long as the discretization cut points aren't picked to purposely obscure the relationship.

Your coding scheme will yield identical numerical results with the dummy coding since an indicator for x=5 is identical to an indicator to x'=25.

I would generally avoid entering the categorical variables as continuous.

• To clarify, are you saying that instead of having two variables--an ordinal one coded 1:5 and a squared version of that ordinal one--that I should instead take the original one and spin it out into five dummy variables instead (15 minutes or les = 1, otherwise 0; 15 to 30 minutes = 1, otherwise 0; etc.)? – coip Jan 22 '20 at 18:41
• Yes, that is right. – Dimitriy V. Masterov Jan 22 '20 at 18:44