[Rd] Factors
Therneau, Terry M., Ph.D.
therne@u @end|ng |rom m@yo@edu
Sat Oct 25 17:15:53 CEST 2025
Peter wrote:
A related issue that has bugged me "forever" is that we treat ordered factors as if their levels are equidistant even when that is patently untrue. The use of polynomial contrasts for ordered factors reflects this - it would really be more sensible to use e.g. successive differences or (ick!) Helmert contrasts for the ordered case and reserve poly() for factors with actual numerical levels. To me, this effectively makes ordered factors conceptually useless.
I actually fall into the opposite camp. We teach students that they *must* code factors as having non-equal increments but that continuous variables are okay s is (the old interval vs. ordinal dichotomy). In my medical work, a lot of the categorical variables actually are close to evenly spaced, a disease grade for instance, since that is what the original authors of the scale were trying to do. It is the continuous variables that violate equal spacing most violently. A cardiac ejection fraction drop from 70 to 60 is "meh", a drop from 30 to 20 is "I hope your affairs are in order". We don't check this nearly often enough.
Also, I use as.integer(factor) quite when creating a an analysis data set from input data. It's just another tool for creating new variables.
Terry T.
[[alternative HTML version deleted]]
More information about the R-devel
mailing list