34
$\begingroup$

I am using a logit model. My dependent variable is binary. However I have an independent variable which is categorical and contains the responses: 1.very good, 2.good, 3.average, 4.poor and 5.very poor. So, it is ordinal ("quantitative categorical"). I am not sure how to handle this in the model. I am using gretl.

[Note from @ttnphns: Although the question says the model is logit (because the dependent is categorical), the crucial issue - ordinal independent variables - is basically alike, be the dependent categorical or quantitative. Therefore the question is equally relevant to, say, linear regression too - as it is to logistic regression or other logit model.]

$\endgroup$
4
  • $\begingroup$ My dependent variable takes value 0 and 1, i have 6 independent variable, 3 of them are categorical these variable are like "how do you rate local health services in your area? how do you rate local transportation in your area and how do you rate police services in your area? the responses are very good, good, average, poor and very poor. $\endgroup$
    – rahmat
    Commented Feb 12, 2016 at 14:49
  • $\begingroup$ @Tim If the dependent variable is binary, then there is no need for any ordinal regression. The implication is to handle an ordinal predictor using indicator (dummy) variables. $\endgroup$
    – Nick Cox
    Commented Feb 12, 2016 at 14:52
  • $\begingroup$ thanks tim, if i am not mistaken what you say is that i should create dummy for all the categories?? for instance i have five response (very good, good, average, poor and very poor) for one indep varible, so i should create 5 dummies. $\endgroup$
    – rahmat
    Commented Feb 12, 2016 at 14:58

3 Answers 3

22
$\begingroup$

The problem with ordinal independent variable is that since, by definition, the true metric intervals between its levels are not known, no appropriate type relationship - apart from umbrella "monotonic" - can be assumed apriori. We have to do something about it, for example - to "screen or to combine variants" or to "prefer what maximizes something".

If you insist on treating your likert rating IV as ordinal (rather than interval or nominal) I've got a pair of alternatives for you.

  1. Use polynomial contrasts I.e. each such predictor used in the model enters not only linearly but also quadratically and cubically. So, not only linear, but more general, monotonic effect can be captured (the linear effect corresponds to the predictor kept as scale/interval and the other two effects tastes it as having nonqual intervals). Additionally, dummies of each predictor could be entered as well, which will test for the nominal/factorial effect. In the end of all that, you know how much your predictor acts as factor, how much as linear covariate, and how much as nonlinear covariate. This option is easy to do in almost any regression (linear, logistic, other generalized-linear models). It will consume dfs, so the sample size should be large enough.
  2. Use optimal scaling regression. This approach transforms monotonically an ordinal predictor into an interval one so as to maximize linear effect on the predictand. CATREG (categorical regression) is an implementation of this idea in SPSS. One problem of your specific case is that you want to do logistic, not linear regression but CATREG is not logit model based. I think this obstacle is relatively minor since your predictand is only 2-category (binary): I mean you might still do CATREG for optimal scaling, then do final logistic regression with the optained transformed scale predictors.
  3. Note also that in simple case of one scale or ordinal DV and one ordinal IV Jonckheere-Terpstra test might be a reasonable analysis instead of regression.

There could be other suggestions, too. The three above are what come to my mind just instantly reading your question.

Let me recommend you also to visit these threads: Associating between nominal and scale or ordinal; Associating between ordinal and scale. They could be helpful despite that they are not about specifially regressions.

But these threads are about regressions, particularly logistic: you must look inside: one, two, three, four, five.

$\endgroup$
4
  • 1
    $\begingroup$ (+1) (1) You can also use only the first few polynomial contrasts if you think they're enough. (2) Defining predictors from the response in the same data set should come with a health warning. (3) You can also penalize discrepancy between the coefficients of adjacent levels - see stats.stackexchange.com/q/77796/17230. $\endgroup$
    – Scortchi
    Commented Feb 12, 2016 at 16:15
  • 1
    $\begingroup$ @Scortchi, Thank you for the comment. Regarding (2) - yes, in particular, it is of course more reliable to do optimal scaling on on a separate subset of the data on which the final regression will be done. (3) - thanks, too, I'll get myself acquainted with it. $\endgroup$
    – ttnphns
    Commented Feb 12, 2016 at 16:30
  • 1
    $\begingroup$ Another option is to use an aditive model, and represent the ordinal independent variable via a spline. $\endgroup$ Commented Apr 18, 2016 at 8:45
  • 2
    $\begingroup$ @kjetilbhalvorsen, Yes it is possible, thank you. This option however is already implied in Pt 2 because one of the methods of optimal scaling for ordinal variables uses spline. $\endgroup$
    – ttnphns
    Commented Apr 18, 2016 at 10:19
8
$\begingroup$

Just to add to the other excellent answers: A modern way of handling it could be via an additive model, representing the ordinal independent variable via a spline. If you are quite sure the effect of the variable is monotone, you could restrict to a monotone spline. (For an example of monotone splines in use, see Looking for function to fit sigmoid-like curve).

In R, if you make the ordinal predictor an "ordered factor" (with for instance the code ord <- factor(sample(1:5,20,replace=TRUE),ordered=TRUE) ) then in a linear model it will be represented via orthogonal polynomials.

$\endgroup$
1
  • 6
    $\begingroup$ It would be nice just a bit expand it, to include a few more details how it will work with ordinal predictors. $\endgroup$
    – ttnphns
    Commented Apr 18, 2016 at 11:12
2
$\begingroup$

There have been a lot of compromises that handwave the relationship. The default polynomial contrasts are far from ideal, although I'm sure some would vehemently argue this. I have found that stairstep contrasts manage to capture a monotonic, ordered variable's effects quite well.

ordered_factor <- function(fact_var) {
  ord_fact <- factor(fact_var, ordered=TRUE)
  categories <- levels(fact_var)
  n_cat <- length(categories)
  cont <- matrix(0, n_cat, n_cat-1)
  cont[col(cont)<row(cont)] <- 1
  rownames(cont) <- categories
  colnames(cont) <- paste(categories[2:n_cat], 
     categories[1:(n_cat-1)],
                          sep=" vs. ")
  contrasts(ord_fact) <- cont
  return(ord_fact)
}

This is from https://aarongullickson.netlify.app/post/better-contrasts-for-ordinal-variables-in-r/

$\endgroup$
1
  • 2
    $\begingroup$ The R brms Bayesian modeling package handles ordinal predictors in the most elegant way, automatically. This saves degrees of freedom by fully using the ordinal nature of the predictor. $\endgroup$ Commented Nov 9, 2023 at 13:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.