Debian Codegraph @

man/tidy.coxph.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/survival-coxph.R
3 \name{tidy.coxph}
4 \alias{tidy.coxph}
5 \alias{coxph_tidiers}
6 \title{Tidy a(n) coxph object}
7 \usage{
8 \method{tidy}{coxph}(x, exponentiate = FALSE, conf.int = FALSE, conf.level = 0.95, ...)
9 }
10 \arguments{
11 \item{x}{A \code{coxph} object returned from \code{\link[survival:coxph]{survival::coxph()}}.}
12
13 \item{exponentiate}{Logical indicating whether or not to exponentiate the
14 the coefficient estimates. This is typical for logistic and multinomial
15 regressions, but a bad idea if there is no log or logit link. Defaults
16 to \code{FALSE}.}
17
18 \item{conf.int}{Logical indicating whether or not to include a confidence
19 interval in the tidied output. Defaults to \code{FALSE}.}
20
21 \item{conf.level}{The confidence level to use for the confidence interval
22 if \code{conf.int = TRUE}. Must be strictly greater than 0 and less than 1.
23 Defaults to 0.95, which corresponds to a 95 percent confidence interval.}
24
25 \item{...}{For \code{tidy()}, additional arguments passed to \code{summary(x, ...)}.
26 Otherwise ignored.}
27 }
28 \description{
29 Tidy summarizes information about the components of a model.
30 A model component might be a single term in a regression, a single
31 hypothesis, a cluster, or a class. Exactly what tidy considers to be a
32 model component varies across models but is usually self-evident.
33 If a model has several distinct types of components, you will need to
34 specify which components to return.
35 }
36 \examples{
37 \dontshow{if (rlang::is_installed(c("survival", "ggplot2"))) withAutoprint(\{ # examplesIf}
38
39 # load libraries for models and data
40 library(survival)
41
42 # fit model
43 cfit <- coxph(Surv(time, status) ~ age + sex, lung)
44
45 # summarize model fit with tidiers
46 tidy(cfit)
47 tidy(cfit, exponentiate = TRUE)
48
49 lp <- augment(cfit, lung)
50 risks <- augment(cfit, lung, type.predict = "risk")
51 expected <- augment(cfit, lung, type.predict = "expected")
52
53 glance(cfit)
54
55 # also works on clogit models
56 resp <- levels(logan$occupation)
57 n <- nrow(logan)
58 indx <- rep(1:n, length(resp))
59 logan2 <- data.frame(
60 logan[indx, ],
61 id = indx,
62 tocc = factor(rep(resp, each = n))
63 )
64
65 logan2$case <- (logan2$occupation == logan2$tocc)
66
67 cl <- clogit(case ~ tocc + tocc:education + strata(id), logan2)
68
69 tidy(cl)
70 glance(cl)
71
72 library(ggplot2)
73
74 ggplot(lp, aes(age, .fitted, color = sex)) +
75 geom_point()
76
77 ggplot(risks, aes(age, .fitted, color = sex)) +
78 geom_point()
79
80 ggplot(expected, aes(time, .fitted, color = sex)) +
81 geom_point()
82 \dontshow{\}) # examplesIf}
83 }
84 \seealso{
85 \code{\link[=tidy]{tidy()}}, \code{\link[survival:coxph]{survival::coxph()}}
86
87 Other coxph tidiers:
88 \code{\link{augment.coxph}()},
89 \code{\link{glance.coxph}()}
90
91 Other survival tidiers:
92 \code{\link{augment.coxph}()},
93 \code{\link{augment.survreg}()},
94 \code{\link{glance.aareg}()},
95 \code{\link{glance.cch}()},
96 \code{\link{glance.coxph}()},
97 \code{\link{glance.pyears}()},
98 \code{\link{glance.survdiff}()},
99 \code{\link{glance.survexp}()},
100 \code{\link{glance.survfit}()},
101 \code{\link{glance.survreg}()},
102 \code{\link{tidy.aareg}()},
103 \code{\link{tidy.cch}()},
104 \code{\link{tidy.pyears}()},
105 \code{\link{tidy.survdiff}()},
106 \code{\link{tidy.survexp}()},
107 \code{\link{tidy.survfit}()},
108 \code{\link{tidy.survreg}()}
109 }
110 \concept{coxph tidiers}
111 \concept{survival tidiers}
112 \value{
113 A \code{\link[tibble:tibble]{tibble::tibble()}} with columns:
114 \item{estimate}{The estimated value of the regression term.}
115 \item{p.value}{The two-sided p-value associated with the observed statistic.}
116 \item{statistic}{The value of a T-statistic to use in a hypothesis that the regression term is non-zero.}
117 \item{std.error}{The standard error of the regression term.}
118
119 }