Skip to content
Prev 256557 / 398506 Next

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