[R] linear contrasts in coxph?

john_philip_lawo at baxter.com john_philip_lawo at baxter.com
Thu Apr 17 10:49:05 CEST 2008

Hello everyone,

I was trying to calculate linear contrasts with coxph via the contrasts
function, but I'm not sure if it is correct.
First, all the statistics change, if I state 2 contrasts instead of 3.
Second, stipulating common linear contrasts does not even nearly produce an
expected result (i.e. -1,1,0,0 should lead to nonsignificatn result, as
group A and B are not differing very much)
So, I suppose a contrast like -1,0,0,1 isn't just first versus last group,
but I didn't found anything on that yet.
Do you have an idea?
Kind reagrds,

x <- 40
weeka <- round(rnorm (x,4,0.3),0)
weekb <- round(rnorm (x,4,0.4),0)
weekc <- round(rnorm (x,8,0.6),0)
weekd <- round(rnorm (x,12,0.9),0)
week  <- c(weeka, weekb,weekc, weekd)
cens  <- round(runif((4*x),0.4,1),0) # 0 = censored
treat <- as.factor(c(rep("A",x),rep("B",x), rep("C",x), rep("D",x)))

S <- Surv(week,cens)

contrasts(treat, how.many=3) <- contr.sum(4); contrasts(treat)
summary(coxph(formula=S~treat, robust=TRUE))

contrasts(treat, how.many=2) <- contr.sum(4); contrasts(treat)
summary(coxph(formula=S~treat, robust=TRUE))

contrasts(treat, how.many=3) <- matrix(ncol=3, nrow=4, c(-3,-1,1,3,
-1,0,1,0,  -1,1,0,0)); contrasts(treat)
summary(coxph(formula=S~treat, robust=TRUE))

John-Philip Lawo

Baxter Innovations GmbH

Wagramer Straße 17-19
IZD Tower 24th floor
A-1220 Vienna
Phone: +43-(0)1-20100-3480

The information transmitted is intended only for the per...{{dropped:13}}

More information about the R-help mailing list