autoplot.emfrail function

Plots for emfrail objects using ggplot2

Plots for emfrail objects using ggplot2

## S3 method for class 'emfrail' autoplot(object, type = c("hist", "hr", "pred", "frail"), newdata = NULL, lp = NULL, strata = NULL, quantity = "cumhaz", type_pred = c("conditional", "marginal"), conf_int = "adjusted", conf_level = 0.95, individual = FALSE, ...)

Arguments

  • object: emfrail object, typically result of emfrail()
  • type: One (or more) of hist for a histogram of the estimated frailty values, hr for a plot of the conditional and marginal hazard ratio between two cases, pred for the predicted conditional and marginal cumulative hazard or survival for one case, frail for a caterpillar plot of the ordered frailty estimates with confidence intervals, where available.
  • newdata: A data.frame with values of the covariates. For type == "hr" the hazard ratio between the first two rows of newdata is calculated. For type == "pred" the prediction for the first row of newdata is calculated.
  • lp: A numeric vector of values of the linear predictor, each corresponding to a case. For type == "hr" the hazard ratio between the first two values of lp is calculated. For type == "pred" the prediction for the first value of lp is calculated.
  • strata: The name of the strata (if applicable) for which the prediction should be made.
  • quantity: One of c("cumhaz", "survival") for type == "pred"; see quantity in predict.emfrail
  • type_pred: One of c("conditional", "marginal") for type == "pred"; see type in predict.emfrail
  • conf_int: One of c("regular", "adjusted") for type == "pred"; see conf_int in predict.emfrail
  • conf_level: The width of the confidence interval for type == "pred"; see conf_level in predict.emfrail
  • individual: Logical, for type == "pred" to be used for drawing a curve when the rows of newdata refer to the same individual; see individual in predict.emfrail
  • ...: Further arguments to be passed on to ggplot (ignored)

Returns

A list of ggplot2 objects corresponding to the required plots, or one ggplot2 if only one plot is selected

For the catterpillar plot, in the case of the gamma frailty model, the vertical lines represent the 0.025 and 0.975 quantiles of the posterior gamma distribution. For other distributions, this quantity is not easy to calculate (at least not in closed form) and only the frailty estimates are shown.

Note

It's normal for autoplot to give a warning of the type Warning: Ignoring unknown aesthetics: id. This is because, in ggplot2 terms, the id aesthetic is not recognized. This is correct, and for any practical purpose this will not make a difference (you can safely ignore the warnings). However, this makes it easier to create an interactive plot out of the resulting object.

Examples

mod_rec <- emfrail(Surv(start, stop, status) ~ treatment + number + cluster(id), bladder1, control = emfrail_control(ca_test = FALSE, lik_ci = FALSE)) # Histogram of the estimated frailties autoplot(mod_rec, type = "hist") # Ordered estimated frailties (with confidence intervals, for gamma distribution) autoplot(mod_rec, type = "frail") # hazard ratio between placebo and pyridoxine newdata1 <- data.frame(treatment = c("placebo", "pyridoxine"), number = c(1, 3)) autoplot(mod_rec, type = "hr", newdata = newdata1) # predicted cumulative hazard for placebo, and number = 1 autoplot(mod_rec, type = "pred", newdata = newdata1[1,]) # predicted survival for placebo, and number = 1 autoplot(mod_rec, type = "pred", quantity = "survival", newdata = newdata1[1,]) # predicted survival for an individual that switches from # placebo to pyridoxine at time = 15 ## Not run: newdata2 <- data.frame(treatment = c("placebo", "pyridoxine"), number = c(1, 3), tstart = c(0, 15), tstop = c(15, Inf)) autoplot(mod_rec, type = "pred", quantity = "survival", newdata = newdata2, individual = TRUE) ## End(Not run)

See Also

predict.emfrail, summary.emfrail, plot.emfrail.

  • Maintainer: Theodor Adrian Balan
  • License: GPL (>= 2)
  • Last published: 2019-09-22