[R] Design package lrm summary and factors

Frank E Harrell Jr f.harrell at vanderbilt.edu
Fri Apr 4 14:23:29 CEST 2008

sj wrote:
> Hello, I have question regarding the lrm function and estimating the odds
> ratio between different levels of a factored variable.
> The following code example illustrates the problem I am having. I have a
> data set with an outcome variable (0,1) and an input variable (A,B,C). I
> would like to estimate the effect of C vs B, but when I perform the summary
> I only get A vs B and A vs C, even though I specify that I want to see C vs
> B.  Am  I  missing something, any help is appreciated.
> outcome<-sample(rep(c(0,1),10000),1000)
> input <- sample(rep(c("A","B","C"),10000),1000)
> dset <-data.frame(cbind(outcome,input))
> dd <- datadist(dset)
> options(datadist='dd')
> mod <- lrm(outcome ~ input,data=dset,x=TRUE,y=TRUE)
> summary(mod,est.all=FALSE,input=c("C","B"))

The x=c(val1,val2) notation works for continuous predictors.  For your 
case just specify input='B' and you will get odds ratios against 'B'.


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

More information about the R-help mailing list