[R] Ordinal Independent Variables

Frank E Harrell Jr
Mon, 22 May 2006 22:55:57 -0000

Rick Bilonick wrote:
> When I run "lrm" from the Design package, I get a warning about
> contrasts when I include an ordinal variable:
>
> Warning message:
> Variable ordfac is an ordered factor.
>  You should set
>
options(contrasts=c("contr.treatment","contr.treatment"))
> or Design will not work properly. in: Design(eval(m, sys.parent()))
>
> I don't get this message if I use glm with family=binomial. It produces
> linear and quadratic contrasts.
>
> If it's improper to do this for an ordinal variable, why does glm not
> balk?
>
> Rick B.

Standard regression methods don't make good use of ordinal predictors
and just have to treat them as categorical.  Design is a bit picky about
this.  If the predictor has numeric scores for the categories, you can
get a test of adequacy of the scores (with k-2 d.f. for k categories) by
using scored(predictor) in the formula.  Or just create a factor( )
variable to hand to Design.
--
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University