Skip to content
Prev 156848 / 398506 Next

odds ratio: how to create reference

You notice that your reference is for the SAS-procedure glm?!

To play around and since you provided no data example I've created some 
data (by an idea from Frank Harrell jr. 
http://www.biostat.wustl.edu/archives/html/s-news/2002-04/msg00103.html)

n <- 30
treat <- rep(c('a','b','c'), length.out=n)
lg<- log(1.2)*(treat=='b')+log(1.5)*(treat=='c')   # here the intercept 
is assumed to be 0 which means that there is an even chance of having 
y=1 or y=0 when treat is 'a'.
y <- ifelse(runif(n) <= plogis(lg), 1, 0)
trf<-as.factor(treat)

To have a first look at the data you can do
table(y,treat)

and you can fit your model via
mm<-glm(y~trf,family=binomial(link="logit"))

and to get your odds ratios
exp(coef(mm))

you may look at the model matrix to see that treatment contrasts 
correspond to use two dummies for "b" and "c" and an intercept term 
(which here refers to the reference level "a")
model.matrix(mm)

hth again.



Bunny, lautloscrew.com schrieb: