[R] setting contrasts for a logistic regression

Frank E Harrell Jr f.harrell at vanderbilt.edu
Sat Nov 14 20:53:02 CET 2009


w_poet wrote:
> Hi everyone,
> 
> I'm doing a logistic regression with an ordinal variable. I'd like to set
> the contrasts on the ordinal variable. However, when I set the contrasts,
> they work for ordinary linear regression (lm), but not logistic regression
> (lrm):
> 
> ddist = datadist(bin.time, exp.loc)
> options(datadist='ddist')
> contrasts(exp.loc) = contr.treatment(3, base = 3, contrasts = TRUE)
> lrm.loc = lrm(bin.time ~ exp.loc, data = Dataset)
> 
> In this case, lrm still uses exp.loc = 1 as the base, at least in terms of
> notation, even though I set exp.loc = 3 as the base.
> 
> Is there a way to set contrasts for lrm?
> 
> Thanks for any advice,
> Stephen
> 
> 

In the Design package and its replacement the rms package, the package 
wants control of the contrasts used during fitting.  But one should not 
in my view be too concerned with this, as after-the-fit contrasts are 
simple to get using the contrast.rms or contrast.Design functions.  They 
use the philosophy that getting predicted values is the safest way to go 
because you don't need keep track of contrasts/coding.  The summary and 
plot function in rms and Design are also helpful here.

Frank

-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University




More information about the R-help mailing list