Survival analysis compares the statistical strength of predictors for events encoded as occuring or censored in concert with a time variable. It can be parametric or non-parametric.
Questions tagged [survival]
445 questions
3
votes
1 answer
Equal sign changes rendering of legend labels in autoplot of a survfit object
I am using the survival package to make Kaplan-Mayer estimates of survival curves by group and then I plot out the said curves using packages ggfortify and survminer. All works fine except the legend labels for plotting. I want to present N sizes of…

altynbei
- 87
- 1
- 8
3
votes
1 answer
How can I get predictions from spline terms with a coxme model in R?
I've read that the best way to report the effect of spline terms on an outcome is to plot the predicted probabilities. I've been able to do this using the frailty coxph model in the survival package, by creating a new dataset with a dummy individual…

Ee Cheng Ooi
- 41
- 5
3
votes
1 answer
How to facet with ggsurvplot_df()?
From ggsurvplot doc, I can facet a ggplot object as below.
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Facet ggsurvplot() output by
# a combination of factors
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Fit (complexe) survival…

Afiq Johari
- 1,372
- 1
- 15
- 28
3
votes
2 answers
Estimating density from interval [start, stop] data in R
Description
The motivation for this question is from clinical/epidemiological research, wherein studies often enroll patients and then follow them for variable lengths of time.
The distribution of age at study entry is often of interest and is…

user1231088
- 337
- 3
- 8
3
votes
1 answer
Creating new Stat with survival::survfit object failing (NA removed from data in compute_group)
I want to create a new stat which calculates interval-censored survival with survival::survfit.formula. But I seem to get a wrong data frame in the compute_group function, and I struggle to find the reason for it.
Creating a data frame with exactly…

tjebo
- 21,977
- 7
- 58
- 94
3
votes
1 answer
Removing percent sign in ggsurvplot R
I have the following code where I am building a survival curve with percentages instead of proportions. I am also breaking the survival time by tens. I would like to remove the percent symbols from the following plot as I would like to add that to…

sparkh2o
- 254
- 1
- 4
- 16
3
votes
0 answers
Unable to plot p values when using facet.by from ggsurvplot. Error message: "variable lengths differ"
I have a problem that I don't know how to solve. And it seems to be related to my data set (or is it?). Indeed, I am actually able to plot different p values when using facet.by when I use your example from issue#205 via the "colon" data set.…

CroixJeremy_2
- 41
- 2
3
votes
1 answer
Is there a way to obtain event probability from a coxme model?
I would like to obtain prediction of an event probability from a coxme model, for a given values of my explanatory variables, and at a given timestep. My data are structured like this:
# Generate data
set.seed(123)
mydata <- data.frame(Site =…

Julien Barrère
- 51
- 4
3
votes
1 answer
How to add shadow of margin of error to a diagramm
I try to create a survival prediction' diagramm
library("survival")
# fit regression
res.cox <- coxph(Surv(time, status) ~ age + sex + wt.loss, data = lung)
res.cox
Fit a new data
sex_df <- with(lung,
data.frame(sex = c(1, 2),
…

Edward
- 4,443
- 16
- 46
- 81
3
votes
0 answers
How can I avoid right-truncated subjects being dropped?
I'm doing a survival analysis about the time some individual components remain in the source code of a software project, but some of these components are being dropped by the survfit function.
This is what I'm doing:
library(survival)
data <-…

elhoyos
- 849
- 9
- 19
3
votes
1 answer
Stratified log-rank test in R for counting process form data?
Background: at half-year follow up times for 4y, patients may switch to a different medication group. To account for this, I've converted survival data into counting process form. I want to compare survival curves for medication groups A, B, and C.…

neal
- 33
- 5
3
votes
0 answers
ggadjustedcurves, fun="cumhaz" does not work
In the 'survminer' package I have been able to construct adjusted curves using cox model but this only shows me the surival function. When I try to input "events" or "cumhaz" into fun= option this only gives me the same survival function. I found…

mindhabits
- 421
- 1
- 3
- 10
3
votes
2 answers
Plot KM curve using survfit in R without strata
I want to plot a KM curve and get median survival data from the survfit() object but I don't want to split by strata - I want to know the whole population.
fit <- survfit(Surv(Time, Status) ~ Group, data = A)
eg. I don't want to have ~ Group

Crispin
- 33
- 3
3
votes
0 answers
R - Computing residuals for flexsurvreg or aftreg object
I'm estimating accelerated failure time survival models with time-varying covariates and would like to compute the deviance residuals for my estimated models.
For fixed-time covariates this is easy to achieve with survival::survreg and…

Lino Ferreira
- 435
- 4
- 13
3
votes
1 answer
Count-process datasets for Non-proportional Hazard (Cox) models with interaction variables
I am trying to run a nonproportional cox regression model featuring an interaction-with-time variable, as described in Chapter 15 (section 15.3) of Applied Longitudinal Data Analaysis by Singer and Willett. However I cannot seem to get answers that…

llewmills
- 2,959
- 3
- 31
- 58