0
$\begingroup$

Do I have to perform any transformation on the variance-covariance matrix computed by either survreg or flexsurvreg? Also, the covariance values have opposite signs between those two functions. Why?

Example:

fitw <- survreg(Surv(futime, fustat) ~ 1, data = ovarian, dist="weibull")
fitw$var
        (Intercept) Log(scale)
(Intercept)  0.08568966 0.03385160
Log(scale)   0.03385160 0.06431534

fitw$icoef
(Intercept)  Log(scale) 
7.1110381  -0.1026105 


fitw2 <- flexsurvreg(Surv(futime, fustat) ~ 1, data = ovarian, dist="weibull")
fitw2$cov
        shape       scale
shape  0.06431532 -0.03385157
scale -0.03385157  0.08568962

fitw2$coefficients
shape     scale 
0.1026105 7.1110381 

Ultimately, I'd like to construct bounds on reliability as explained here. So I'll need the variances of $\beta$ (shape) and $\eta$ (scale), as well as the covariance between them. And I guess its sign matters. What about the units? Should I apply any transformation to the values calculated by those two functions?

$\endgroup$
1
$\begingroup$

You have to be very careful with just how the Weibull distribution is parameterized within a function, as there are alternate choices. You will note that the value and the variance for the Intercept in the first model are the same as those for scale in the second, and the value for log(scale) in the first model is the negative of the shape in the second, with the same variances, indicating that the parameterizations differ between the models. The help page for survreg explains:

There are multiple ways to parameterize a Weibull distribution. The survreg function embeds it in a general location-scale family, which is a different parameterization than the rweibull function, and often leads to confusion.

survreg's scale = 1/(rweibull shape)

survreg's intercept = log(rweibull scale)

The manual page for flexsurvreg says:

The Weibull parameterisation is different from that in survreg, instead it is consistent with dweibull. The "scale" reported by survreg is equivalent to 1/shape as defined by dweibull and hence flexsurvreg. The first coefficient (Intercept) reported by survreg is equivalent to log(scale) in dweibull and flexsurvreg.

The manual page for dweibull describes its parameterization as:

The Weibull distribution with shape parameter a and scale parameter b has density given by

f(x) = (a/b) (x/b)^(a-1) exp(- (x/b)^a), for x > 0.

That parameterization by dweibull agrees with that referred to by the reliability measure you cite, with the dweibull shape a corresponding to shape $\beta$ and the dweibull scale b corresponding to scale $\eta$.

Be ruthlessly consistent in the parameterization. It would seem to be safest here to use the flexsurvreg parameterization, as that agrees with your intended downstream use. The confidence intervals based on the covariance matrix just use the coefficient estimates and their (co)variances directly, so there's no need to transform. Even then, look at plots, check carefully, and make sure that things make sense whenever you come upon a potentially confusing parameterization like you face with the Weibull distribution.

$\endgroup$
5
  • $\begingroup$ Yes, I noticed that elements in indices [1,1] and [2,2] are swapped between fitw$var and fitw2$cov. My main concern is if I should transform those values to follow the parametrization that uses $\beta$ and $\eta$ in the other link. Also, the opposite signs for the off-diagonal elements is strange. $\endgroup$ – Bruno Sep 28 '20 at 16:29
  • $\begingroup$ @Bruno my guess is that there is also a sign difference in one of the corresponding coefficient values between the two models. Please edit the question to include the actual coefficient estimates for the two models, not just the covariance matrices, to help make sure. Weibull parameterization differences provide many places where things can go unexpectedly wrong. $\endgroup$ – EdM Sep 28 '20 at 16:59
  • $\begingroup$ Thanks. Updated the question with the cofficients. Now it's clear where the sign difference comes from. Still not clear if I should use the positive value for the covariance in order to be compatible with the $\beta$ and $\eta$ parametrization. The remaining question is if I need to apply any transformation to the variance-covariance matrix at all. $\endgroup$ – Bruno Sep 28 '20 at 17:24
  • $\begingroup$ @Bruno added more to the answer to deal with your last comment. $\endgroup$ – EdM Sep 28 '20 at 18:38
  • $\begingroup$ Thanks a lot! :) $\endgroup$ – Bruno Sep 28 '20 at 19:56

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.