# load libraries for models and data
library(survival)
# fit model
sr <- survreg(
Surv(futime, fustat) ~ ecog.ps + rx,
ovarian,
dist = "exponential"
)
# summarize model fit with tidiers + visualization
tidy(sr)
augment(sr, ovarian)
glance(sr)
# coefficient plot
td <- tidy(sr, conf.int = TRUE)
library(ggplot2)
ggplot(td, aes(estimate, term)) +
geom_point() +
geom_errorbarh(aes(xmin = conf.low, xmax = conf.high), height = 0) +
geom_vline(xintercept = 0)
Run the code above in your browser using DataLab