Interpreting Weibull parameters from survreg
Asked Answered
K

2

12

I am trying to generate an inverse Weibull distribution using parameters estimated from survreg in R. By this I mean I would like to, for a given probability (which will be a random number in a small simulation model implemented in MS Excel), return the expected time to failure using my parameters. I understand the general form for the inverse Weibull distribution to be:

X=b[-ln(1-rand())]^(1/a)

where a and b are shape and scale parameters respectively and X is the time to failure I want. My problem is in the interpretation of the intercept and covariate parameters from survreg. I have these parameters, the unit of time is days:

             Value   Std. Error    z    p
(Intercept)     7.79    0.2288  34.051  0.000
Group 2        -0.139   0.2335  -0.596  0.551
Log(scale)     0.415    0.0279  14.88   0.000
Scale= 1.51 

Weibull distribution
Loglik(model)= -8356.7   Loglik(intercept only)= -8356.9 
Chisq = 0.37 on 1 degrees of freedom, p= 0.55 
Number of Newton-Raphson Iterations: 4 
n=1682 (3 observations deleted due to missing values)

I have read in the help files that the coefficients from R are from the "extreme value distribution" but I'm unsure what this really means and how I get 'back to' the standard scale parameter used directly in the formulae. Using b=7.79 and a=1.51 gives nonsensical answers. I really want to be able to generate a time for both the base group and 'Group 2'. I also should note that I did not perform the analysis myself and cannot interrogate the data further.

Katricekatrina answered 2/2, 2012 at 14:18 Comment(0)
C
14

This is explained in the manual page, ?survreg (in the "examples" section).

library(survival)
y <- rweibull(1000, shape=2, scale=5)
r <- survreg(Surv(y)~1, dist="weibull")
a <- 1/r$scale      # Approximately 2
b <- exp( coef(r) ) # Approximately 5
y2 <- b * ( -ln( 1-runif(1000) ) ) ^(1/a)
y3 <- rweibull(1000, shape=a, scale=5)
# Check graphically that the distributions are the same
plot(sort(y), sort(y2))
abline(0,1)
Cotswolds answered 2/2, 2012 at 22:32 Comment(4)
Thank you, this has answered my question and my model works. If I were trying to estimate the inverse Weibull for 'Group2' rather than the base group, how would I combine the 'Group 2' coefficeint with the (Intercept) coefficient? does group2_b=base_b*(exp(-.139))? Thanks againKatricekatrina
@DavidT86: No. The estimated "effect" for group b on the log-scale is Intercept + beta_Grp_2, so you need to add those values: b= exp(7.79 +(-.139))Punctuality
@BondedDust: In case I have other covariates that are not binary, i should get the scale by exp(intercept+coeff1*val_1 + coeff2*val_2...) where val_i is the value of the i-th covariate. Is that correct?Suborder
@statBeginner: That does not sound correct, at least if I am interpreting your question correctly. It's difficult to know since 'scale' is ambiguous and you are not describing the goals very well. You may be using 'scale' where I would be using 'estimated effect'. I think posting a full example is called for ... not well handled in comments to a three year-old question.Punctuality
P
2

The key is that the shape parameter the rweibull generates is the inverse of the shape parameter the survreg inputs

Primateship answered 3/2, 2012 at 8:22 Comment(1)
No - rweibull's shape is the reciprocal of survreg's scale, according to the Examples section of ?survreg. (And I assume you mean "output", not "inputs".)Peery

© 2022 - 2024 — McMap. All rights reserved.