survival

How can assign an offset term in coxph function in R, which later can be used in the “mstate” package?

江枫思渺然 提交于 2021-01-28 11:51:22
问题 I am trying to use mstate package in R , for which I have to use coxph function using strata command. Here is a sample code: library(mstate) tmat <- trans.illdeath() tg <- data.frame(stt=rep(0,6),sts=rep(0,6), illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1), dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1)) tg$patid <- factor(2:7,levels=1:8,labels=as.character(1:8)) tt <- matrix(c(rep(NA,6),tg$illt,tg$dt),6,3) st <- matrix(c(rep(NA,6),tg$ills,tg$ds),6,3) mslong<-msprep(time=tt,status=st,trans=tmat) models <-

How to do survival analysis in R with time-varying exposure to an intervention, using Surv and coxph?

有些话、适合烂在心里 提交于 2021-01-07 03:52:29
问题 I have survival data in this format, with a time-varying exposure to Intervention: ID start stop status Intervention 1 2 14 0 0 2 2 5 0 0 3 2 3 0 0 3 3 10 1 1 4 5 8 0 0 5 6 10 0 0 For example, for patient ID #3: from day 2 to day 3, the patient has not yet received the intervention (Intervention = 0), but starting on day 3 and lasting until day 10 (when the patient dies), the patient has received the intervention (Intervention = 1). I thought that I could then estimate the time-varying effect

Customising line type in adjusted survival curves ggadjustedcurves (survminer, ggplot2)

╄→гoц情女王★ 提交于 2020-12-12 09:45:08
问题 I'm trying to plot an adjusted survival curve, but struggling with changing the line types by group. I'm able to customise other aspects of the plot using typical ggplot2 language, but I've hit a wall with changing line type. Example: library(survival) library(survminer) fit2 <- coxph( Surv(stop, event) ~ size + strata(rx), data = bladder ) ggadjustedcurves(fit2, variable = "rx", data = bladder, method = "average", palette = c("#E69F00", "#56B4E9"), size = 1.3, legend = "right", legend.title

Customising line type in adjusted survival curves ggadjustedcurves (survminer, ggplot2)

北慕城南 提交于 2020-12-12 09:44:36
问题 I'm trying to plot an adjusted survival curve, but struggling with changing the line types by group. I'm able to customise other aspects of the plot using typical ggplot2 language, but I've hit a wall with changing line type. Example: library(survival) library(survminer) fit2 <- coxph( Surv(stop, event) ~ size + strata(rx), data = bladder ) ggadjustedcurves(fit2, variable = "rx", data = bladder, method = "average", palette = c("#E69F00", "#56B4E9"), size = 1.3, legend = "right", legend.title

how to fix 'Error: variable lengths differ (found for 'input$s')' in R Shiny

邮差的信 提交于 2020-05-29 08:23:30
问题 I'm trying to make a simple shiny ap for creating kaplan-meier survival curves that are stratified by selection the user makes. When I code the KM calculation statically (with the column name thorTr) it works but the calculation and plot is static. When I replace with input$s I get ERROR:variable lengths differ (found for 'input$s') I've tried looking at other code which use as.formula and paste, but I don't understand and couldn't get to work. But I am a new R and Shiny user so maybe I didn

how to fix 'Error: variable lengths differ (found for 'input$s')' in R Shiny

旧街凉风 提交于 2020-05-29 08:23:18
问题 I'm trying to make a simple shiny ap for creating kaplan-meier survival curves that are stratified by selection the user makes. When I code the KM calculation statically (with the column name thorTr) it works but the calculation and plot is static. When I replace with input$s I get ERROR:variable lengths differ (found for 'input$s') I've tried looking at other code which use as.formula and paste, but I don't understand and couldn't get to work. But I am a new R and Shiny user so maybe I didn

unable to plot kaplan-meier curve with survfit object from a list using ggsurvplot

浪尽此生 提交于 2020-01-23 08:20:26
问题 I am trying to plot Kaplan-Meyer curve using ggsurvplot from survminer package. I'm unable to plot it when I pass a survfit object saved in a list. Let me use lung dataset as a example. Everything works below: library("survival") library("survminer") fit <- survfit(Surv(time, status) ~ sex, data = lung) ggsurvplot(fit, conf.int = TRUE, risk.table.col = "strata", palette = c("#E7B800", "#2E9FDF"), xlim = c(0, 600)) Now I do survfit on two variables and save the model result in a list. Then

How to add arrows to forest plot in survminer (ggforest)

瘦欲@ 提交于 2020-01-03 05:38:06
问题 I was wondering if there was a way to add two arrows to the x-axis of a forest plot, similar to what is shown in this example: How to add arrows to a forest plot? (this code does not work on ggforest) Here is the sample code: library(survival) library(survminer) model <- coxph(Surv(time, status) ~ sex + rx + adhere, data = colon ) ggforest(model) colon <- within(colon, { sex <- factor(sex, labels = c("female", "male")) differ <- factor(differ, labels = c("well", "moderate", "poor")) extent <-