2
$\begingroup$

I have some difficulties understanding the use of the formula in survival::survreg. I am trying to estimate weibull parameters for different groups of data. For convenience I want to use the formula to group the data. Please consider the following code:

library(survival)

a <- rweibull(500, scale = 4, shape = 2)
a.ind <- rep('a', length(a))
b <- rweibull(700, scale = 6, shape = 3)
b.ind <- rep('b', length(b))

A <- data.frame(ttf = c(a,b), group = c(a.ind, b.ind))

fit <- survreg(Surv(ttf)~group, data = A, dist = "weibull")

fit.a <- survreg(Surv(a)~1, dist = "weibull")
fit.b <- survreg(Surv(b)~1, dist = "weibull")

My question is, why are the estimated parameters from fit different to the parameters estimated in fit.a and fit.b (e.g. coef(fit)[1] != coef(fit.a))?

$\endgroup$
2
  • $\begingroup$ This really isn't really a programming question. You really seem to have a question about how the parameters are estimated in this particular statistical model such that individual contributions are not additive. This question can probably better be answered by a statistician than a programmer. Consider posting to Cross Validated instead. $\endgroup$
    – MrFlick
    Dec 12 '14 at 20:55
  • $\begingroup$ @MrFlick: Anybody who read the help pages in pkg:survival could answer the question. $\endgroup$
    – DWin
    Dec 12 '14 at 22:37
2
$\begingroup$

When you fit the model, regardless of the number of groups, only one scale parameter is estimated. If you fix it, then the shape parameter estimates will be the same as you expect:

fit.scale <- survreg(Surv(ttf)~group, data = A, dist = "weibull", scale = 0.5)
fit.a.scale <- survreg(Surv(a)~1, dist = "weibull", scale = 0.5)

> coef(fit.scale)[1]
(Intercept) 
   1.376969 
> coef(fit.a.scale)
(Intercept) 
   1.376969 

(Also note that, as documented in ?survreg.distributions, the parameterization of the survreg Weibull distribution is different from that of rweibull. You can find the conversions in the examples at the bottom of ?survreg.)

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy