survival-analysis

Create a ggplot2 survival curve with censored table

笑着哭i 提交于 2019-12-31 06:50:30
问题 I am trying to create a Kaplan-Meier plot with 95% confidence bands plus having the censored data in a table beneath it. I can create the plot, but not the table. I get the error message: Error in grid.draw(both) : object 'both' not found. library(survival) library(ggplot2) library(GGally) library(gtable) data(lung) sf.sex <- survfit(Surv(time, status) ~ sex, data = lung) pl.sex <- ggsurv(sf.sex) + geom_ribbon(aes(ymin=low,ymax=up,fill=group),alpha=0.3) + guides(fill=guide_legend("sex")) pl

Create a ggplot2 survival curve with censored table

与世无争的帅哥 提交于 2019-12-31 06:50:27
问题 I am trying to create a Kaplan-Meier plot with 95% confidence bands plus having the censored data in a table beneath it. I can create the plot, but not the table. I get the error message: Error in grid.draw(both) : object 'both' not found. library(survival) library(ggplot2) library(GGally) library(gtable) data(lung) sf.sex <- survfit(Surv(time, status) ~ sex, data = lung) pl.sex <- ggsurv(sf.sex) + geom_ribbon(aes(ymin=low,ymax=up,fill=group),alpha=0.3) + guides(fill=guide_legend("sex")) pl

How to test PH assumption with Schoenfeld residuals with simulated paths in presence of competing events

廉价感情. 提交于 2019-12-24 23:42:46
问题 I've obtained Schoenfeld residuals for testing PH for Fine & Gray's Cox regression model in presence of competing events with cmprsk. Here's the code: fg<-crr( fu_m, event, diabetes, failcode=1, cencode=0, na.action=na.omit, gtol=1e-06, maxiter=10, variance=TRUE) fg$res fg$uft par(mfrow = c(1,1), mar = c(4.5,4,2,1)) for(j in 1:ncol(fg$res)) fg$u scatter.smooth(fg$uftime, fg$res[,j], main = names(fg$diabetes)[j], xlab = "Failure time", ylab = "Schoenfeld residuals") Here's the output: > fg$res

MLR - Survival analysis with time-dependent data

独自空忆成欢 提交于 2019-12-24 14:35:05
问题 I am using mlr and would like to be able to use the extended version of the Cox PH model for right-censored, time dependent covariates. This is what I have tried, following the vignette on time-dependent covariates https://cran.microsoft.com/web/packages/survival/vignettes/timedep.pdf (section 3.4): library(survival) library(mlr) data(pbc) temp <- subset(pbc, id <= 312, select=c(id:sex, stage)) # baseline pbc2 <- tmerge(temp, temp, id=id, death = event(time, status)) #set range pbc2 <- tmerge

Interval censored data: Cox proportional hazard and surival difference in R

纵饮孤独 提交于 2019-12-24 07:30:32
问题 there is quite a lot of information (internet and textbooks) on how to do survival analysis in R with the survival package. But I don't find any information on how to do this when you have left censored data. Problem background: I have a self constructed data set with published survival data. Usually the event time and the date of the last follow-up (right censoring) is given. There is however one study that only states that the event happened before day 360. So I left censored this data.

ggsurvplot_facet returns: “Error in grDevices::col2rgb(colour, TRUE) : invalid color name” when used inside a function

﹥>﹥吖頭↗ 提交于 2019-12-24 00:22:32
问题 I'm trying to plot survival curves for several variables facet by the variable sex with the ggsurvplot_facet() function. When I apply my code to a single fitted model, it works fine. However, when I try to use the same code within a function or within a for loop, it fails to plot all the survival curves that should be plotted and returns an error. I would perform this plotting in ggsurvplot_facet() itself if it allowed as input a list of survfit elements, in the same way ggsurvplot() does,

Plotting predicted survival curves for continuous covariates in ggplot

我是研究僧i 提交于 2019-12-23 19:58:40
问题 How can I plot survival curves for representative values of a continuous covariate in a cox proportional hazards model? Specifically, I would like to do this in ggplot using a "survfit.cox" "survfit" object. This may seem like a question that has already been answered, but I have searched through everything in SO with the terms 'survfit' and 'newdata' (plus many other search terms). This is the thread that comes closest to answering my question so far: Plot Kaplan-Meier for Cox regression In

WinBUGS Weibull Network Meta-Analysis

五迷三道 提交于 2019-12-22 04:15:08
问题 I am currently working on a meta-analysis of survival data across several clinical trials. To do this, I have code from a published analysis using the same methodology. However, when running this code using the data from the published analysis, I am unable to replicate their results. In fact, the results fail to converge to any kind of reasonable estimate. The code itself (not including the data) should be correct as it comes directly from the authors. I assume the problem has to do w/

coxph() X matrix deemed to be singular;

核能气质少年 提交于 2019-12-18 14:45:52
问题 I'm having some trouble using coxph(). I've two categorical variables:"tecnologia" and "pais", and I want to evaluate the possible interaction effect of "pais" on "tecnologia"."tecnologia" is a variable factor with 2 levels: gps and convencional. And "pais" as 2 levels: PT and ES. I have no idea why this warning keeps appearing. Here's the code and the output: cox_AC<-coxph(Surv(dados_temp$dias_seg,dados_temp$status)~tecnologia*pais,data=dados_temp) Warning message: In coxph(Surv(dados_temp

Survival analysis combining survfit and ggplot objects

穿精又带淫゛_ 提交于 2019-12-13 04:14:32
问题 A little background that might be useful. I am in a position that I have two plots that need to be combined. I have used the "survival" package to generate a Kaplan-Meier curve from a set of data. I have also created and used a custom function to generate survival curves (from the same data, after being processed by WinBUGS) I generate my K-M curve in the following way. library("survminer") library("survival") KM.est <- survfit(Surv(IPD.data[,1],IPD.data[,2])~1, data=IPD.data,type="kaplan