[R] Ordinal Independent Variables

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue May 23 09:27:05 CEST 2006


On Mon, 22 May 2006, Frank E Harrell Jr wrote:

> 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.

Contrasts in S/R are used to set the coding of factors, and model.matrix() 
does IMO 'make good use of ordinal predictors'.

I don't know what is meant by 'Standard regression methods': the 
charitable interpretation is that these are the overly restrictive methods 
used by certain statistical packages.  (I first learnt of the use of 
polynomial codings for ordinal factors in the late 1970s, when I first 
learnt anything about ANOVA, so to me they are 'standard'.)

So are you saying this is a design deficiency in package Design, or that 
the authors of S ca 1991 were wrong to allow arbitrary contrasts?

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list