Skip to content

ordered factor and unordered factor

3 messages · Greg Snow, Peng Yu

#
I don't understand under what situation ordered factor rather than
unordered factor should be used. Could somebody give me some examples?
What are the implications of order vs. unordered factors? Could
somebody recommend a textbook to me?
#
Mostly it is a conceptual difference.  An unordered factor is one where there is no inherent order to the levels, examples:

Color of car
Race
Nationality
Sex
State/Country of birth
Etc.

In the above, the order of the levels could be changed without it really changing the meaning (think of the order of bars in a bar chart).  We may want to print/plot in some specific order such as alphabetic for easy lookup or based on the summary values of another vector for nice looking plots, but there is no overriding reason why we would order color as blue/green/red vs. green/red/blue, etc.

Ordered factors have some natural order, for example maybe you are studying a drug and have doses labeled as Low, Medium, and High.  It makes the most sense to print and plot in that order rather than alphabetically (High, Low, Medium).  Any continuous variable that has been cut into categories (best not to do this, but if done) has a natural order.  Survey questions where you response can range from strongly disagree to strongly agree are usually ordered (but there may be disagreement on what the correct ordering is).

In R the most apparent effects of using ordered vs. factor is in how they print out and how some modeling functions default to handling them (the default contrasts for ordered factors is different, rpart treats ordered factors differently).

Hope this helps,
#
Why the contrast matrices are different for order and unordered factored?
On Mon, Nov 9, 2009 at 1:12 PM, Greg Snow <Greg.Snow at imail.org> wrote: