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
0
votes
1 answer
De-identifying survival or flexsurvreg objects in R
Please consider the following:
I need to provide some R code syntax to analyse data with the flexsurv package. I am not allowed to receive/analyse directly or on-site. I am however allowed to receive the analysis results.
Problem
When we run the…

Frederick
- 810
- 8
- 28
0
votes
1 answer
Fitted coxph model varies by ordering of terms in formula with time-varying strata and clusters
I encountered strange behavior in the survival package in R, and before I reach out to the package maintainer directly, I'm hoping folks smarter than me can tell me if it's not a bug but rather something that is more statistically nuanced (hence my…

psboonstra
- 111
- 2
0
votes
1 answer
Render a plot generated from a fitted model in reactive for shiny
I am building a shiny app and I would like to render a plot that is generated using the basic plot function in R into the mainPanel. The data used for the plot is simulated directly from a fitted model but I am not able to extract values into a data…

Amer
- 2,131
- 3
- 23
- 38
0
votes
0 answers
R: New column with survival probabilities given the event and censoring
I have the following dataframe:
df <-read.table(header=TRUE, text="id time event
1 90 1
2 87 0
3 50 1
4 54 0
5 30 0
6 15 1
7 20 1
…

Economist_Ayahuasca
- 1,648
- 24
- 33
0
votes
1 answer
importing data and fitting survival model
I am trying to import data from Stata to R and fit a survival model. I did the following:
library(haven)
data <- read_dta("C:/Users/user/Desktop/data.dta")
View(data)
install.packages(c("survival",…

Hatem Ali
- 1
- 2
0
votes
1 answer
Create a time-to-event kaplan meier plot with multiple events in R
I want to create a kaplan meier plot. Most tutorials focus on a binary survival (death/survival), but in my case, I would like to plot the time to an event (1,2,3 times switch in medication). Is this possible?
Here is some example data to illustrate…

Inkling
- 469
- 1
- 4
- 19
0
votes
0 answers
Is there a R function to determine the time point when survival is no longer significantly different between two groups?
I'm trying to compare survival between two groups. While overall survival shows to be not significantly different, survival at fixed time points proves to be significantly different at set time points in the first five years.
I was wondering if…

Kathi
- 1
0
votes
1 answer
Censored survival in survfit & ggsurvplot
I draw Kaplan-Meier survival curve using survfit and ggsurvplot (60 months survival) :
surv <- survfit(Surv(time, status) ~ group, data = dataK)
ggsurvplot(surv,size = 1, censor.size = 6,risk.table = TRUE,pval = TRUE, conf.int = F,pval.coord =…

B_slash_
- 309
- 2
- 17
0
votes
0 answers
Pairwise differences between survreg survival curves (survival package) using emmeans
I'm using survreg from the 'survival' package to model survival curves. I'm interested in obtaining pairwise differences between levels of factors. I've tried using pairwise_survdiff from the 'survminer' package, but the function won't work with…

Thomas Moore
- 192
- 1
- 12
0
votes
2 answers
Episode splitting in survival analysis by the timing of an event in R
Is it possible to split episode by a given variable in survival analysis in R, similar to in STATA using stsplit in the following way: stsplit var, at(0) after(time=time)?
I am aware that the survival package allows one to split episode by given cut…

elliezee
- 113
- 4
0
votes
1 answer
Is there an inverse function for the method quantile.survfit in the survival package?
Using a survfit object, I can extract quantiles like this:
library('survival')
fit <- survfit(Surv(time, status) ~ 1, data = aml)
quantile(fit)[[1]]
#25 50 75
#12 27 43
Is there a function to perform the inverse? Pass a vector of quantiles, and…

SmokeyShakers
- 3,372
- 1
- 7
- 18
0
votes
1 answer
Making point predictions using Cox proportional hazard
I am using the pysurvival library to model with the Cox proportional hazard model (CPH). Instead of getting the survival curves, I am interested in getting point predictions. In the library, the function predict_survival returns an array-like…

andKaae
- 173
- 1
- 13
0
votes
1 answer
Irregular Interval based representation of survival data in R
I have the following dataset:
df =
id Time A
1 3 0
1 5 1
1 6 1
2 8 0
2 9 0
2 12 1
I want to do two things: i) have a starting time of -1 across all ids, and ii) split the time into two columns; start and end while preserving…

Economist_Ayahuasca
- 1,648
- 24
- 33
0
votes
1 answer
Reshape complex time to event data in R
I have the following data frame where I have the beginning of the time, the end of the time AND a Date where the individual got the observations A or B.
df =
id Date Start_Date End_Date A B
1 2 1 4 1 0
1 3 1 4 …

Economist_Ayahuasca
- 1,648
- 24
- 33
0
votes
1 answer
Multiple imputation using mice package
I'm not R user but I use R only to rum multiple imputation using mice package. Since I updated R from version 3.6.3 to version 4.0.4, I encountered problem with the imputed data when I call it from R to STATA. The problem is when I run a survival…