[R] linear contrasts in coxph?

From: <john_philip_lawo_at_baxter.com>
Date: Thu, 17 Apr 2008 10:49:05 +0200

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,
John

Code:
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

Biostatistician
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}}



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 17 Apr 2008 - 09:51:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Apr 2008 - 11:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive