# Coding as a categorical or continuous variable?

I have a question/IV in my study which has been answered:

1- No
2- Do not know
3- Sometimes
4- Yes


I was advised to remove the answer 2 (all do not know responses) and to regard these as missing data as there is not much value in this response for the question.

Thus, I ended up recoding with

1- No
2- Sometimes
3- Yes


Would this variable be considered continuous or categorical in a binary logistic regression?

Inputting this as it is a continuous factor in a binary logistic regression reveals it is a significant effect: those who scored higher (3) (which would mean yes) were more likely to do the DV behaviour.

However, I am very doubtful of the statistical correctness of this. Should this variable be considered categorical in my regression?

Should I keep the do not know responses? If so, and if I am regarding it as continuous what order of this response (i.e. from 1 to 4) would be most appropriate?

• How much data do you have? – CodesInChaos Apr 13 '18 at 20:35
• it is a regression model for 2 separate samples, each has aprox 80 respondants data – Ali Apr 13 '18 at 20:47
• consider an ordinal response model ... – Ben Bolker Apr 13 '18 at 20:50
• the order of the responses doesn't really matter for my aim, i have figured it should just be coded as a categorical variable in a binary regression so i can see the effect of each level instead but your suggestion is appreciated. Do you have insight into how to interpret a negative constant value in binary regression model by any chance? – Ali Apr 13 '18 at 20:55
• Negative constant for one category means prediction is less than that for the base level category. The amount will vary given the logit link function. – Nick Cox Apr 14 '18 at 7:41

Given these categories as data beyond my control, I would code

1 No
2 Sometimes
3 Yes
4 Don't know


on these grounds:

1. Sometimes sounds weaker than Yes, which is more emphatic.

2. Don't know doesn't usually belong in an ordered sequence.

Then some analyses will call for ignoring 4 and some don't. All depends on the question being asked: for example, are you describing the data or modelling?

But I think it's wrong to call "Don't know" missing. We all answer questionnaires too. If I am allowed to say "Don't know" as one of various possible answers, that is not at all equivalent to my refusing or declining to answer the question. As an occasional survey participant as well as a statistically minded person I object to data being analysed like that.

There is no case for calling this variable continuous. It's discrete. 1 to 3 alone is ordered, 1 to 4 is just nominal or unordered.

A context of logistic regression doesn't change how you think about the variable, unless it is being considered as a response and you are choosing between ordinal and multinomial logistic.

EDIT

Thinking more about this, it's hard to see that "Sometimes" and "Yes" are mutually exclusive! What are the questions? Do you ever eat meat, drink alcohol, smoke tobacco?

There is a separate problem if people were presented with these answers in this order:

1- No
2- Do not know
3- Sometimes
4- Yes


Then it's entirely possible that, rationally or not, some people might regard that as an ordered scale. For example, "Do you approve of the behaviour of prominent politician?". There is something of a case for saying that "Don't know" is in between the extremes, as in "I don't know enough or don't want to be judgmental about the topic". But then people are being expected to know the difference between "Don't know" and "Sometimes". That can happen: I had no idea what was involved in a minor medical condition until it happened to me and was named and explained.

Without qualitative evidence about how the questionnaire was received or understood, it's very hard to do more than speculate.

• so would you reccomend that i code it as above and then use it as a categorical variable in the binary logistic model? I am modelling the data by the way – Ali Apr 13 '18 at 13:13
• As said, it depends. Either 1 to 3 above is used and can be regarded as ordered, or 1 to 4 is used and can be regarded as unordered or nominal. – Nick Cox Apr 13 '18 at 13:14
• Sorry, I can't advise how to use SPSS (I have forgotten every detail I ever knew from using it about three times 40 years ago) and in any case that's off-topic here. Interpreting output I can't see is tricky too. If you can focus on the statistical aspect that might be a fair separate question here. But, frankly, SPSS documentation or textbooks must explain this somewhere. Do read advice in the Help Center on software-specific questions. – Nick Cox Apr 13 '18 at 13:33
• Can you get antibiotics without prescription? Is that a question about an individual's personal medical circumstances or about their knowledge of the system in a particular country? – Nick Cox Apr 13 '18 at 15:14
• @Ali: I mean that if you're going to treat the predictor as categorical in any case, there's no conundrum with regard to the don't knows - they're just a 4th level. (If you did want to treat the yes - sometimes - no scale as numeric, you could add an indicator variable for don't know.) – Scortchi - Reinstate Monica Apr 13 '18 at 19:57

(Assuming for simplicity that we're treating "Do not know" as missing:) The three simple approaches are:

1. Code it as a categorical covariate. If, for instance, you use "No" as the reference level, then you get two coefficients from your regression: a) the log-odds of the outcome (all else being equal, roughly speaking) for a respondent who answers "Sometimes" versus one who answers "No"; and b) the log-odds of the outcome for a respondent who answers "Yes" versus one who answers "No". Disadvantage, you don't get a value for answering "Yes" versus "Sometimes".

2. Use it as a continuous variable. Disadvantage, this assumes that the difference between "No" and "Sometimes" is the same magnitude as the difference between "Sometimes" and "Yes".

3. I guess you could decide that all you care about is a binary choice -- "Yes" versus "No" or "Sometimes", and re-code it as a boolean variable. But that throws out information.

There are more complex choices as well. This answer has some ideas; and this one, and the links it points to, give you many more.

• I ran the test according to option 1- produced the result i was expecting and easy to interpret! But as as soon as i added do not know, some coefficients become negative and it all got rather confusing. Only issue is that i need the do not know responses as it is improper to just discard them – Ali Apr 13 '18 at 15:44
• If you want to get more complicated, you can code "no" as 0, "yes" 1, and "sometimes as x, then see what value of x gives the best result. – Acccumulation Apr 13 '18 at 19:45