# How to justify the use of categorical variables as continuous variables in logistic regression?

One question again to be clarified: Can I use the variables as noted below [(3) a,b,c etc] as continuous variables in my logistic regression and if so what will be my explanation in the paper that I am writing.

I have the following sets of variables:

1. A Categorical (binary) variable Ayurveda and Allopathy
2. Test variable (binary) "Spirituality is a scientific subject": Agree and Disagree
3. Then I have a number of participant perspectives/characteristics such as:

• (a) Do you believe there is life after death: 1) yes, 2) no, 3) not sure
• (b) To what extent do you consider spiritual 1) Very 2) moderate 3) slightly 4) not at all
• (c) How often would you say the experience of illness increase patients’ awareness of and focus on R/S: 1) Rarely 2) Never 3) sometimes 4) Often 5) Always 6) Not apply
• (d) etc= several more such variables with multiple choices as above

• why do you want to use them as continuous variables? They seem like factors (in R) to me. If using R, just fit a glm including the variables as is, and R will do the right thing. Aug 27, 2012 at 7:19

I would say no. Including these categorical variables as continuous regressors assumes that a one unit change in any of the multiple choice variables results in the same effect on the outcome. For example, you are assuming that going from [1)Very] to [2)moderate] has the same marginal effect as going from [3)slightly] to [4)not at all].

To me this is an overly restrictive assumption. Thankfully, it is straightforward to estimate this model without this assumption: include the categorical regressors as factor variables. This breaks each of the categorical regressors down into a series of dummy variables. To do this with R you can use the factor() function inside the glm function:

glm(y~factor(x),binomial())

or in stata use the xi and i prefixes:

xi:logit y i.x

In addition to the good advice you have gotten so far, I'd say that once you fix up the problems in the ordering, one thing to do to justify treating these as continuous is to run the model both ways (treating each as continuous and categorical) and see if there are big differences in the predicted probabilities.

If there are not, then the two models are making similar predictions and the one that treats these as continuous is simpler.

What is "big"? You have to decide.

• but I assume the interpretation should be different even if you get the same result.
– Moj
May 12, 2017 at 10:01

To be honest, your question indicated that your statistic knowledge is not really sufficient to do a paper without additional expertise. Good ways forward would be to either read up on regression modelling or to consult with a statistican at your university/department.

1) and 2) is not an issue. Binary variables are usually encoded as 0 for negative and 1 for positive. Mathematically they are treated the same, however you think of them.

For 3) it is more difficult. You can sometimes treat ordinal (ordered) variables as continous, but you will have to check this model afterwards. This being said, with a) I would tend to be doubtful "not sure" is a intermediate of "yes" and "no" in this case. With b) it might be possible. c) has a very strange ordering of the levels, which would have to be changed. Also note that "not apply" can be hardly considered to be on the same continous scale as the others.

Also note that I consider the survey design to be bad, especially regarding the odd ordering of the answers mentioned above and the fact that there is no consistency regarding the low/high ordering or the number of in-between levels at all. Please get expert help.

Some general points on treating ordinal factors as continous:

Reasons for doing this includes having less terms in the model (therefore more degrees of freedom) and a model that is easier to interpret. This is especially the case when looking at interactions. With interactions of five level ordinal variables you can run out of degrees of freedom very quickly, unless you model them as being continous. However, you will always need to look at the model diagnostics carefully, to see whether you have a good model fit.

Krish, you must make sure your dependent variable is binary (only 0,1 responses) if you want a logistic regression. Moreover it should have an underlying continuous variable with logistic distribution. If your underlying continuous variable is normal, use probit model instead. If your dependent variable is nominal (having more than 2 categories) then use nominal logistic regression, which is just an extension of logistic regression. If your dependent variable is ordinal in nature, use ordinal regression. Remember with all these regressions your interpretation should be based on the reference category (the category compared to which you are interested to make comments). For further reading and interpretation I would suggest you to read 'An Introduction to Generalized Linear Models' (second edition) by Annette J. Dobson.

If your goal is only to interpret in general which variables affect your dependent variable, that is, you don't want so many beta coefficients to interpret, you may try categorical regression with optimal scaling. This is available in SPSS (Analyze > Regression > Optimal scaling). It optimally quantifies the binary, nominal, ordinal variables. Then you can get only one beta coefficient for each variable. Additionally it accounts for the possible non-linearity in your data. But I would suggest you to first meet a statistician with your data and check these issues.

• Could you explain what you mean by "an underlying continuous variable with logistic distribution"? AFAIK, the logistic distribution is unconnected to logistic regression, despite the shared name.
– whuber
Aug 27, 2012 at 13:50
• @whuber: I am a novice statistician, but what I was taught was-there is an underlying variable $Z$ and the outcomes are $I(Z\le\mu)=1$ or $I(Z>\mu)=0$. Here $\mu$ is the threshold. Again, $\mu=x^{'}\beta$. So, $P[Z\le x^{'}\beta]=P[Y=1|x]=\theta$ (say). This $\theta$ is the parameter of the Bernoulli distribution of $Y|x,\beta$. $P[Z\le x'\beta]$ is the cumulative distribution of unobserved $Z$. If this takes the form of a logistic cumulative distribution then we use logit (or logistic regression) model. If takes the form of normal cumulative distribution then we use probit model. Is it right? Aug 27, 2012 at 21:09
• @whuber, if $y^{\star}_{i} = \beta_0 + \beta_1 x + \varepsilon_i$ where $\varepsilon_i$ follows a logistic distribution then $y_i = \mathcal{I}(y^{\star}_i > 0)$ conforms to the model $$\log \left( \frac{P(y_i = 1|x)}{P(y_i=0|x)} \right) = \beta_0 + \beta_1 x$$ This follows directly from the form of the CDF of the logistic distribution. You can also verify this with a quick simulation: x <- rnorm(200); y <- (1 + 2*x + rlogis(200))>0; summary(glm(y~x,family="binomial")) Aug 27, 2012 at 21:10
• @macro Thank you! I had forgotten that formulation altogether. Blain, Macro proves you right. In practice it's hard to tell the difference between the two formulations; in many situations choosing logistic or probit is partly a matter of preference, intended interpretation, and custom.
– whuber
Aug 27, 2012 at 21:12
• Thank you @macro for this nice clarification. I am quite bad at my equation writing. Thanks whuber yes actually I was searching over net and found that they resemble quite a lot always. For example ![this graph][google.com/imgres?imgurl=http://upload.wikimedia.org/wikipedia/… Aug 27, 2012 at 21:26