Description Usage Arguments Value Note See Also Examples
View source: R/autoplot.emfrail.R
Plots for emfrail objects using ggplot2
1 2 3 4 5 |
object |
|
type |
One (or more) of |
newdata |
A |
lp |
A numeric vector of values of the linear predictor, each corresponding to a case. For |
strata |
The name of the strata (if applicable) for which the prediction should be made. |
quantity |
One of |
type_pred |
One of |
conf_int |
One of |
conf_level |
The width of the confidence interval for |
individual |
Logical, for |
... |
Further arguments to be passed on to 'ggplot' (ignored) |
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.
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.
predict.emfrail
, summary.emfrail
, plot.emfrail
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 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)
|
Loading required package: survival
Warning messages:
1: In Surv(start, stop, status) :
Stop time must be > start time, NA created
2: In Surv(start, stop, status) : Invalid status value, converted to NA
3: In Surv(start, stop, status) :
Stop time must be > start time, NA created
4: In Surv(start, stop, status) : Invalid status value, converted to NA
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Warning: Ignoring unknown aesthetics: id
Warning: Ignoring unknown aesthetics: id
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.