Search code examples
gtsummarysurvival

How do I get gtsummary to exponentiate a weibull model?


I'm running a Weibull regression using the survreg function in the survival package.

I'd like to use gtsummary to then produce a table of the results.

But when I try to exponentiate the beta coefficient, it just returns me the same beta value - but says it's exp(B) in the header.

reprex:

library(survival)
library(gtsummary)

fit_w<-survreg(Surv(time, status) ~ sex, dist='weibull', data=lung)

tbl_regression(fit_w)

tbl_regression(fit_w,
               exponentiate=TRUE)

Solution

  • The default tidying function is broom::tidy.survreg() which does NOT have an exponentiate argument for survreg() models. The reason it is not there is because most of the models created with this function are NOT proportional hazards models, meaning that you should not exponentiate because the result is not a hazard ratio.

    If you confidently feel like your model should have an exponentiated coef, then you can write a small wrapper for broom::tidy.survreg() that includes a exponentiate argument.