Learn R Programming

frailtyEM (version 0.7.2)

summary.emfrail: Summary for emfrail objects

Description

Summary for emfrail objects

Usage

# S3 method for emfrail
summary(object, lik_ci = TRUE, print_opts = list(coef =
  TRUE, dist = TRUE, fit = TRUE, frailty = TRUE), ...)

Arguments

object

An object of class emfrail

lik_ci

Logical. Should the confidence intervals for the frailty parameter be calculated based on the likelihood? If not, they are calculated with the delta method.

print_opts

A list with argumnets that are passed as attributes to the return object; these are used to determine what is printed when the object is accessed.

...

Ignored

Value

An object of class emfrail_summary, with some more human-readable results from an emfrail object.

Details

Regardless of the fitted model, one can expect the following fields in this object: est_dist (an object of class emfrail_distribution) with the estimated distribution, loglik (a named vector with the log-likelihoods of the no-frailty model, the frailty model, the likelihood ratio test statistic and the p-value of the one-sided likelihood ratio test), theta (a named vector with the estimated value of the parameter \(\theta\), the standard error, and the limits of a 95 is a data frame with the following columns: id (cluster identifier), z (empirical Bayes frailty estimates), and optional lower_q and upper_q as the 2.5

For the the PVF or gamma distributions, the field fr_var contains a transformation of theta to correspond to the frailty variance. The fields pvf_pars and stable_pars are for quantities that are calculated only when the distribution is PVF or stable. If the model contains covariates, the field coefmat contains the corresponding details.

See Also

predict.emfrail, plot.emfrail

Examples

Run this code
# NOT RUN {
data("bladder")
mod_gamma <- emfrail(Surv(start, stop, status) ~ treatment + cluster(id), bladder1)
summary(mod_gamma)

# plot the Empirical Bayes estimates of the frailty
# easy way:
plot(mod_gamma, type = "hist")

# a fancy graph:
sum_mod <- summary(mod_gamma)
library(dplyr)
library(ggplot2)

# Create a plot just with the points
pl1 <- sum_mod$frail %>%
  arrange(z) %>%
  mutate(x = 1:n()) %>%
  ggplot(aes(x = x, y = z)) +
  geom_point()

# If the quantiles of the posterior distribution are
# known, then error bars can be added:
if(!is.null(sum_mod$frail$lower_q))
  pl1 <- pl1 + geom_errorbar(aes(ymin = lower_q, ymax = upper_q), alpha = 0.5)

pl1

# The plot can be made interactive!
# ggplot2 gives a warning about the "id" aesthetic, just ignore it
pl2 <- sum_mod$frail %>%
  arrange(z) %>%
  mutate(x = 1:n()) %>%
  ggplot(aes(x = x, y = z)) +
  geom_point(aes(id = id))

if(!is.null(sum_mod$z$lower_q))
  pl2 <- pl2 + geom_errorbar(aes(ymin = lower_q, ymax = upper_q, id = id), alpha = 0.5)

library(plotly)
ggplotly(pl2)

# Proportional hazards test
off_z <- log(sum_mod$frail$z)[match(bladder1$id, sum_mod$frail$id)]

zph1 <- cox.zph(coxph(Surv(start, stop, status) ~ treatment + cluster(id), data = bladder1))

# no sign of non-proportionality
zph2 <- cox.zph(coxph(Surv(start, stop, status) ~ treatment + offset(off_z), data = bladder1))

zph2
# the p-values are even larger; the frailty "corrects" for proportionality.
# }

Run the code above in your browser using DataLab