Michael Haenlein
2011-Apr-12 09:19 UTC
[R] Testing equality of coefficients in coxph model
Dear all, I'm running a coxph model of the form: coxph(Surv(Start, End, Death.ID) ~ x1 + x2 + a1 + a2 + a3) Within this model, I would like to compare the influence of x1 and x2 on the hazard rate. Specifically I am interested in testing whether the estimated coefficient for x1 is equal (or not) to the estimated coefficient for x2. I was thinking of using a Chow-test for this but the Chow test appears to work for linear regression only (see: http://en.wikipedia.org/wiki/Chow_test). Another option I was thinking of is to estimate an alternative model in which the coefficients for x1 and x2 are constraint to be equal and to compare the fit of such a constraint model with the one of an unconstraint one. But again I'm not sure how this can be done using coxph. Could anyone help me out on this please? Thanks, Michael Michael Haenlein Associate Professor of Marketing ESCP Europe Paris, France [[alternative HTML version deleted]]
Dr. Pablo E. Verde
2011-Apr-12 10:03 UTC
[R] Testing equality of coefficients in coxph model
Hi Michael, One way to work out you problem is with bootstrap methods. The following is a toy example that may be help you for you: # test data... library(survival) set.seed(1007) x <- runif(50) mu <- c(rep(1, 25), rep(2, 25)) test1 <- data.frame(Time = qsurvreg(x, mean = mu, scale= 0.5, distribution = "weibull"), Status = rbinom(50,1,0.7), tr = gl(2, 20) ) mod1 <- survreg(Surv(Time, Status) ~ -1 + tr, data = test1) summary(mod1) # Bootstrap function... boot.fun <- function(dat, Ind) { mod1 <- survreg(Surv(Time, Status) ~ -1 + tr, data = dat[Ind,]) b <- coef(mod1) delta <- b[1] - b[2] # statistic of interest delta } # Bootstraping ... library(boot) boot.res <- boot(test1, boot.fun, R = 1999) boot.res boot.ci(boot.res) plot(boot.res, jack = TRUE) # end ... Cheers, Pablo ----- Original Message ----- From: "Michael Haenlein" <haenlein at escpeurope.eu> To: <r-help at r-project.org> Sent: Tuesday, April 12, 2011 11:19 AM Subject: [R] Testing equality of coefficients in coxph model> Dear all, > > I'm running a coxph model of the form: > coxph(Surv(Start, End, Death.ID) ~ x1 + x2 + a1 + a2 + a3) > > Within this model, I would like to compare the influence of x1 and x2 on > the > hazard rate. > Specifically I am interested in testing whether the estimated coefficient > for x1 is equal (or not) to the estimated coefficient for x2. > > I was thinking of using a Chow-test for this but the Chow test appears to > work for linear regression only (see: > http://en.wikipedia.org/wiki/Chow_test). > Another option I was thinking of is to estimate an alternative model in > which the coefficients for x1 and x2 are constraint to be equal and to > compare the fit of such a constraint model with the one of an unconstraint > one. But again I'm not sure how this can be done using coxph. > > Could anyone help me out on this please? > > Thanks, > > Michael > > > > Michael Haenlein > Associate Professor of Marketing > ESCP Europe > Paris, France > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. >
Hi: Another possible approach (untested) would be to compare the two models m1 <- coxph(Surv(Start, End, Death.ID) ~ x1 + x2 + a1 + a2 + a3) m0 <- coxph(Surv(Start, End, Death.ID) ~ I(x1 + x2) + a1 + a2 + a3) anova(m0, m1) This should be able to test H_0: beta_1 = beta_2. If you want to test that they are both equal to a specified [nonzero] constant, that's a different test entirely (e.g., beta_1 = 1 = beta_2) - in that case, offset() might be useful. HTH, Dennis On Tue, Apr 12, 2011 at 2:19 AM, Michael Haenlein <haenlein@escpeurope.eu>wrote:> Dear all, > > I'm running a coxph model of the form: > coxph(Surv(Start, End, Death.ID) ~ x1 + x2 + a1 + a2 + a3) > > Within this model, I would like to compare the influence of x1 and x2 on > the > hazard rate. > Specifically I am interested in testing whether the estimated coefficient > for x1 is equal (or not) to the estimated coefficient for x2. > > I was thinking of using a Chow-test for this but the Chow test appears to > work for linear regression only (see: > http://en.wikipedia.org/wiki/Chow_test). > Another option I was thinking of is to estimate an alternative model in > which the coefficients for x1 and x2 are constraint to be equal and to > compare the fit of such a constraint model with the one of an unconstraint > one. But again I'm not sure how this can be done using coxph. > > Could anyone help me out on this please? > > Thanks, > > Michael > > > > Michael Haenlein > Associate Professor of Marketing > ESCP Europe > Paris, France > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]