# Weibull survival regression variance-covariance matrix

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?

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.

• 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. Commented Sep 28, 2020 at 16:29
• @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.
– EdM
Commented Sep 28, 2020 at 16:59
• 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. Commented Sep 28, 2020 at 17:24