| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/survival-coxph.R |
| 3 |
\name{glance.coxph} |
| 4 |
\alias{glance.coxph} |
| 5 |
\title{Glance at a(n) coxph object} |
| 6 |
\usage{ |
| 7 |
\method{glance}{coxph}(x, ...) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{x}{A \code{coxph} object returned from \code{\link[survival:coxph]{survival::coxph()}}.} |
| 11 |
|
| 12 |
\item{...}{For \code{tidy()}, additional arguments passed to \code{summary(x, ...)}. |
| 13 |
Otherwise ignored.} |
| 14 |
} |
| 15 |
\description{ |
| 16 |
Glance accepts a model object and returns a \code{\link[tibble:tibble]{tibble::tibble()}} |
| 17 |
with exactly one row of model summaries. The summaries are typically |
| 18 |
goodness of fit measures, p-values for hypothesis tests on residuals, |
| 19 |
or model convergence information. |
| 20 |
|
| 21 |
Glance never returns information from the original call to the modeling |
| 22 |
function. This includes the name of the modeling function or any |
| 23 |
arguments passed to the modeling function. |
| 24 |
|
| 25 |
Glance does not calculate summary measures. Rather, it farms out these |
| 26 |
computations to appropriate methods and gathers the results together. |
| 27 |
Sometimes a goodness of fit measure will be undefined. In these cases |
| 28 |
the measure will be reported as \code{NA}. |
| 29 |
|
| 30 |
Glance returns the same number of columns regardless of whether the |
| 31 |
model matrix is rank-deficient or not. If so, entries in columns |
| 32 |
that no longer have a well-defined value are filled in with an \code{NA} |
| 33 |
of the appropriate type. |
| 34 |
} |
| 35 |
\examples{ |
| 36 |
\dontshow{if (rlang::is_installed(c("survival", "ggplot2"))) withAutoprint(\{ # examplesIf} |
| 37 |
|
| 38 |
# load libraries for models and data |
| 39 |
library(survival) |
| 40 |
|
| 41 |
# fit model |
| 42 |
cfit <- coxph(Surv(time, status) ~ age + sex, lung) |
| 43 |
|
| 44 |
# summarize model fit with tidiers |
| 45 |
tidy(cfit) |
| 46 |
tidy(cfit, exponentiate = TRUE) |
| 47 |
|
| 48 |
lp <- augment(cfit, lung) |
| 49 |
risks <- augment(cfit, lung, type.predict = "risk") |
| 50 |
expected <- augment(cfit, lung, type.predict = "expected") |
| 51 |
|
| 52 |
glance(cfit) |
| 53 |
|
| 54 |
# also works on clogit models |
| 55 |
resp <- levels(logan$occupation) |
| 56 |
n <- nrow(logan) |
| 57 |
indx <- rep(1:n, length(resp)) |
| 58 |
logan2 <- data.frame( |
| 59 |
logan[indx, ], |
| 60 |
id = indx, |
| 61 |
tocc = factor(rep(resp, each = n)) |
| 62 |
) |
| 63 |
|
| 64 |
logan2$case <- (logan2$occupation == logan2$tocc) |
| 65 |
|
| 66 |
cl <- clogit(case ~ tocc + tocc:education + strata(id), logan2) |
| 67 |
|
| 68 |
tidy(cl) |
| 69 |
glance(cl) |
| 70 |
|
| 71 |
library(ggplot2) |
| 72 |
|
| 73 |
ggplot(lp, aes(age, .fitted, color = sex)) + |
| 74 |
geom_point() |
| 75 |
|
| 76 |
ggplot(risks, aes(age, .fitted, color = sex)) + |
| 77 |
geom_point() |
| 78 |
|
| 79 |
ggplot(expected, aes(time, .fitted, color = sex)) + |
| 80 |
geom_point() |
| 81 |
\dontshow{\}) # examplesIf} |
| 82 |
} |
| 83 |
\seealso{ |
| 84 |
\code{\link[=glance]{glance()}}, \code{\link[survival:coxph]{survival::coxph()}} |
| 85 |
|
| 86 |
Other coxph tidiers: |
| 87 |
\code{\link{augment.coxph}()}, |
| 88 |
\code{\link{tidy.coxph}()} |
| 89 |
|
| 90 |
Other survival tidiers: |
| 91 |
\code{\link{augment.coxph}()}, |
| 92 |
\code{\link{augment.survreg}()}, |
| 93 |
\code{\link{glance.aareg}()}, |
| 94 |
\code{\link{glance.cch}()}, |
| 95 |
\code{\link{glance.pyears}()}, |
| 96 |
\code{\link{glance.survdiff}()}, |
| 97 |
\code{\link{glance.survexp}()}, |
| 98 |
\code{\link{glance.survfit}()}, |
| 99 |
\code{\link{glance.survreg}()}, |
| 100 |
\code{\link{tidy.aareg}()}, |
| 101 |
\code{\link{tidy.cch}()}, |
| 102 |
\code{\link{tidy.coxph}()}, |
| 103 |
\code{\link{tidy.pyears}()}, |
| 104 |
\code{\link{tidy.survdiff}()}, |
| 105 |
\code{\link{tidy.survexp}()}, |
| 106 |
\code{\link{tidy.survfit}()}, |
| 107 |
\code{\link{tidy.survreg}()} |
| 108 |
} |
| 109 |
\concept{coxph tidiers} |
| 110 |
\concept{survival tidiers} |
| 111 |
\value{ |
| 112 |
A \code{\link[tibble:tibble]{tibble::tibble()}} with exactly one row and columns: |
| 113 |
\item{AIC}{Akaike's Information Criterion for the model.} |
| 114 |
\item{BIC}{Bayesian Information Criterion for the model.} |
| 115 |
\item{logLik}{The log-likelihood of the model. [stats::logLik()] may be a useful reference.} |
| 116 |
\item{n}{The total number of observations.} |
| 117 |
\item{nevent}{Number of events.} |
| 118 |
\item{nobs}{Number of observations used.} |
| 119 |
See survival::coxph.object for additional column descriptions. |
| 120 |
} |