3
$\begingroup$

I am performing linear regression in R and I have a variable called diversityscore which is a value ranging from 1 to 10 indicating #activities a user performs with 1 meaning one activity to 10 meaning all ten activities. I am not sure if this is to be counted as a factor variable or a non-factor variable. How do I make this decision?

(Expanding the question for the comprehensive answer below:...)

If it is (not) a factor, is this true for all ratio variables (with meaningful 0 and equal intervals)? For ex, temperature in Kelvin (assuming discrete values in output), age, etc? How about dates? I'm guessing they must be counted as factors. Can we take nominal and ordinal variables in general to be factors? or any more exceptions that I should be watchful of?

$\endgroup$
2
  • $\begingroup$ Unless you can do 1.5 or 3.78 activities its probably best to make it a factor variable since the activity variable really isn't continuous. $\endgroup$
    – Dan
    Commented Aug 29, 2014 at 19:21
  • $\begingroup$ thank you. I cannot upvote this because of insufficient reputation $\endgroup$
    – rk567
    Commented Aug 29, 2014 at 20:17

2 Answers 2

7
$\begingroup$

It sounds like you're counting activities.

Counts are not factors. They're numeric variables with a meaningful 0 and equal intervals.

Just because they're discrete rather than continuous doesn't make them factors, and you should not in normal circumstances seek to turn them into factors.

Making a count variable a factor throws away a lot of information.

There may be situations where you might seek to treat that "number of activities" as some ordered factor rather than interval, but generally you'd avoid treating it as nominal categories.

(In your particular case, if the effect of adding each new activity to the count is thought to be arbitrary -- so that intervals aren't expected to be equal or even smoothly changing -- then you might treat it as ordered categories, but you'd seek to avoid just making it a factor and throw away the ordering.)


Response to question in comments:

Well I don't want to attach undue importance to the Stevens typology, but since you frame the question that way, I'll mostly use it for the moment. Please note that it's not the only way to think about analysis (there are other typologies, for example), and it's not always helpful -- if it leads you to throw away useful or important information, it's not helping you.

The thing is "being integers" doesn't make it ordinal. Normally, anything with equal intervals is best treated as numerical (at least interval), but it depends on how you're using it in the model (the typology shouldn't drive the analysis; the needs of the analysis should).

Kelvin - to some extent it depends on the model, but discretized temperatures in Kelvin would normally be considered ratio scale (or at least interval scale if the fact that it has a meaningful zero didn't matter for the model); in other typologies they still would be numeric variables.

Age - again, it depends on your model, but age will usually tend to be at least interval (another year is another year, whether you're 15 or 64), and in some cases ratio (for example, if you're looking at lifetime exposure to background radiation, that zero means something). In some cases you might regard it as ordinal.

How about dates? I'm guessing they must be counted as factors.

Must? Well, no. In many cases, you convert them to a time interval from some origin, which makes the converted values (typically) interval, since (again), a year is a year and a day is a day. (Again, however, it depends on the model. In some cases, there's also a particular event date and later dates represent some kind of exposure time or survival time from that event - ratio. In other cases they might be treated as ordered categories.)

Can we take nominal and ordinal variables in general to be factors?

Usually you'd do that, yes. Certainly with nominal variables. With ordered categories generally speaking the ordering contains a lot of information that should be retained, and so it's common to treat the factors differently. Sometimes ordered categories are treated as interval (when people add Likert-scale questionnaire items, for example, to make an actual Likert-scale, but also in other circumstances). R certainly treats ordered factors quite differently.

or any more exceptions that I should be watchful of?

Rather than try to find lists of exceptions (which sounds like a lot of work, and would be unlikely to be complete), it's a matter of considering what the available information is, and how you'll be using it in your model.

$\endgroup$
2
  • $\begingroup$ Thank you! informative! Is this true for all ratio variables (with meaningful 0 and equal intervals)? For ex, temperature in Kelvin (assuming discrete values in output), age, etc? How about dates? I'm guessing they must be counted as factors. Can we take nominal and ordinal variables in general to be factors? or any more exceptions that I should be watchful of? $\endgroup$
    – rk567
    Commented Sep 1, 2014 at 15:14
  • 1
    $\begingroup$ see updated answer. $\endgroup$
    – Glen_b
    Commented Sep 1, 2014 at 20:43
-1
$\begingroup$

Unless you can do 1.5 or 3.78 activities its probably best to make it a factor variable since the activity variable really isn't continuous.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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