survfit_phregr | R Documentation |
Obtains the predicted survivor function for a proportional hazards regression model.
survfit_phregr(
fit_phregr,
newdata,
sefit = TRUE,
conftype = "log-log",
conflev = 0.95
)
fit_phregr |
The output from the |
newdata |
A data frame with the same variable names as those that
appear in the |
sefit |
Whether to compute the standard error of the survival estimates. |
conftype |
The type of the confidence interval. One of |
conflev |
The level of the two-sided confidence interval for the survival probabilities. Defaults to 0.95. |
If newdata
is not provided and there is no covariate, survival
curves based on the basehaz
data frame will be produced.
A data frame with the following variables:
id
: The id of the subject for counting-process data with
time-dependent covariates.
time
: The observed times in the data used to fit
phregr
.
nrisk
: The number of patients at risk at the time point in the
data used to fit phregr
.
nevent
: The number of patients having event at the time point
in the data used to fit phregr
.
cumhaz
: The cumulative hazard at the time point.
surv
: The estimated survival probability at the time point.
sesurv
: The standard error of the estimated survival probability.
lower
: The lower confidence limit for survival probability.
upper
: The upper confidence limit for survival probability.
conflev
: The level of the two-sided confidence interval.
conftype
: The type of the confidence interval.
covariates
: The values of covariates based on newdata
.
stratum
: The stratum of the subject.
Kaifeng Lu, kaifenglu@gmail.com
Terry M. Therneau and Patricia M. Grambsch. Modeling Survival Data: Extending the Cox Model. Springer-Verlag, 2000.
library(dplyr)
# Example 1 with right-censored data
fit1 <- phregr(data = rawdata %>% filter(iterationNumber == 1) %>%
mutate(treat = 1*(treatmentGroup == 1)),
stratum = "stratum",
time = "timeUnderObservation", event = "event",
covariates = "treat")
surv1 <- survfit_phregr(fit1,
newdata = data.frame(
stratum = as.integer(c(1,1,2,2)),
treat = c(1,0,1,0)))
# Example 2 with counting process data and robust variance estimate
fit2 <- phregr(data = heart %>% mutate(rx = as.numeric(transplant) - 1),
time = "start", time2 = "stop", event = "event",
covariates = c("rx", "age"), id = "id", robust = TRUE)
surv2 <- survfit_phregr(fit2,
newdata = data.frame(
id = c(4,4,11,11),
age = c(-7.737,-7.737,-0.019,-0.019),
start = c(0,36,0,26),
stop = c(36,39,26,153),
rx = c(0,1,0,1)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.