Questions tagged [survival]

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.

445 questions
3
votes
1 answer

How to fit frailty survival models in R

Because this is such a long question I've broken it down into 2 parts; the first being just the basic question and the second providing details of what I've attempted so far. Question - Short How do you fit an individual frailty survival model in R?…
gowerc
  • 1,039
  • 9
  • 18
2
votes
1 answer

Is there an R function for fitting survival curves with IPW and competing risks?

I'm trying to fit survival curves: with inverse probability weighting (IPW) taking into account competing risks. In the RISCA package, the function ipw.survival allows to fit survival curves with IPW but not with competing risks. Can anyone help…
Devanto
  • 33
  • 5
2
votes
1 answer

How to reproduce Stata competing-risks survival analysis results in R?

I am attempting to reproduce some survival analysis results published in a journal. The original results were produced in Stata. Here is the code: stset time, id(leadid) failure(c_coup) streg legislature leg_growth_2 gdp_1k chgdpen_fearonlaitin…
w5698
  • 159
  • 7
2
votes
1 answer

Using package::function inside formula in R gives different results (specifically survival::strata inside coxph)

I believed the following two formula calls should be equivalent. install.packages("survival") library(survival) Model 1 coxph(Surv(futime, fustat) ~ age + strata(rx), data=ovarian) Call: coxph(formula = Surv(futime, fustat) ~ age + strata(rx),…
AP30
  • 505
  • 7
  • 18
2
votes
1 answer

Move plot with ggplot

I created this survival plot (dataset=lung) with ggsurvfit which uses ggplot2. library(survival) library(ggplot2) library(ggsurvfit) p <- survfit2(Surv(time, status)~sex, data=lung) p %>% ggsurvfit(type = "survival", linewidth=1) + …
user19745561
  • 145
  • 10
2
votes
0 answers

Discontinuous y-axis in inset plot with `ggplot2`

I am trying to insert a Kaplan-Meier inset "zoom" plot into the same KM plot (when Survival curves are very similar to allow more accurate inspection). This is currently used by many journals. Unfortunately, I find creating an inset plot with a…
q050cr
  • 21
  • 3
2
votes
1 answer

MLR3 Survival Analysis: how to simultaneously perform feature selection & hyperparameter tuning together and get selected_features?

I am trying to fit coxph and parametric models and simultaneously perform feature selection and hyperparameter tuning. I have the following code below where I can use either auto_fselecter or auto_tuner inside resample but not both. How do I do…
Ali Alhadab
  • 101
  • 5
2
votes
1 answer

How to convert a mortality table to generate a Kaplan-Meier plot

I have been using the survival package in R to generate Kaplan-Meier plots using tables of mortality data. I am now trying to generate the same type of plots with new data that is in a different format. I would like to convert the data so it is in…
user964689
  • 812
  • 7
  • 20
  • 40
2
votes
1 answer

How to drop the facet argument using panel.labs with survminer::ggsurvplot_facet?

I use the following code to facet plots in a survival analysis: surv_plot <- ggsurvplot_facet(fit, matrix_surv, facet.by = c("Place","Year"), panel.labs =list(Lieu_libelle = c("Austria","Belgium","Denmark","Finland","Italy"), …
Mata
  • 538
  • 3
  • 17
2
votes
0 answers

lifelines/scikit-survival: Calculation of the expected times

I am trying to understand how to calculate the expected time for the each of my ids in my dataset. I have a dataset that looks like a Dataframe shaped (500,4): ids var1 var2 churn time 0 1.738434 324 0 21.0 1 1.541176 …
2
votes
2 answers

How to predict survival at certain time points, using a survreg model?

Data library(survival) kidney Model model = survreg(Surv(time, censored) ~ sex + age, data = kidney) Call: survreg(formula = Surv(time, censored) ~ sex + age, data = kidney) Coefficients: (Intercept) sexfemale age 8.44411429…
st4co4
  • 445
  • 3
  • 10
2
votes
1 answer

Error in `levels<-`(`*tmp*`, value = as.character(levels)) : factor level [3] is duplicated

I'm trying to plot faceted survival curves with autoplot but the combination of covariates and facetting them duplicates levels within the factors library(survival) library(ggfortify) fit <- survfit( Surv(time, status) ~ inst + sex, …
brucezepplin
  • 9,202
  • 26
  • 76
  • 129
2
votes
0 answers

Error when testing the cox proportional hazard assumption with a frailty term

I am trying to evaluate the proportional hazard assumption of a Cox PH model that includes both an interaction term and a frailty term. When I call cox.zph, I get this error: Error in imatr[kk, kk] : subscript out of bounds I don't get the error…
momce
  • 21
  • 1
2
votes
2 answers

ggforest returns error Error in `[.data.frame`(cbind(allTermsDF, coef[inds, ]), , c("var", "level", : undefined columns selected

I am using the ovarian dataset from the survival package using the following standard code: ovarian$rx <- factor(ovarian$rx, levels = c("1", "2"), labels = c("A", "B")) ovarian$resid.ds <- factor(ovarian$resid.ds, levels = c("1", "2"), labels =…
Nora_R
  • 51
  • 5
2
votes
3 answers

how can I resolve the "undefined columns selected" error for ggforest

How can I resolve the error of undefined columns selected? I have loaded the survminer and the survival packages. cox4<- coxph(formula= Surv(LOS,Mortality)~ BNPcat+HF_dx+Age+Sex+BMI+ Admit_QTc+FI02_comb+Admit_Lactate,data=DF) …
ABC
  • 21
  • 1
  • 3
1 2
3
29 30