Jieyue Li
2013-Dec-30 22:04 UTC
[R] cumulative incidence for mstate in Survival package in R
Dear All, I want to have the cumulative incidence curves for 'mstate' data using Survival package in R. But I got some problems: I. Problem 1: 1. If I only use intercept without any covariates, I can have 'right' cumulative incidence curves (2 for 2 competing risks): library(Survival) fitCI <- survfit(Surv(stop, status*as.numeric(event), type="mstate") ~ 1,data=mgus1, subset=(start==0)) plot(fitCI) 2. If I include one variate ('sex'), I get 4 curves (attached; I guess because there are two levels in 'sex' and 2 competing risks): fitCI <- survfit(Surv(stop, status*as.numeric(event), type="mstate") ~sex,data=mgus1, subset=(start==0)) plot(fitCI) However, I want to just have 2 cumulative incidence curves estimated from several covariates (such as 'sex', 'age', 'alb', etc. in mgus1). Could you please help me to do that? Thank you very much! II. Problem 2: I try using an example from sourcecode.pdf: fit <- survfit(Surv(time, status, type=?mstate?) ~ sex, data=mine) but where can I have the 'mine' data? Thank you! Best, Jieyue -------------- next part -------------- A non-text attachment was scrubbed... Name: Rplot.png Type: image/png Size: 9373 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20131230/4a7a0a41/attachment.png>
Göran Broström
2013-Dec-31 09:59 UTC
[R] cumulative incidence for mstate in Survival package in R
On 12/30/2013 11:04 PM, Jieyue Li wrote:> Dear All, > > I want to have the cumulative incidence curves for 'mstate' data using > Survival package in R. But I got some problems: > I. Problem 1: > 1. If I only use intercept without any covariates, I can have 'right' > cumulative incidence curves (2 for 2 competing risks): > library(Survival)That shouldn't work;)> fitCI <- survfit(Surv(stop, status*as.numeric(event), type="mstate") ~ > 1,data=mgus1, subset=(start==0)) > plot(fitCI) > 2. If I include one variate ('sex'), I get 4 curves (attached; I guess > because there are two levels in 'sex' and 2 competing risks): > fitCI <- survfit(Surv(stop, status*as.numeric(event), type="mstate") > ~sex,data=mgus1, subset=(start==0)) > plot(fitCI) > However, I want to just have 2 cumulative incidence curves estimated from > several covariates (such as 'sex', 'age', 'alb', etc. in mgus1). Could you > please help me to do that? Thank you very much!I suggest that you check the Task Views, under 'Survival' and 'Multistate Models', for instance the 'cmprsk' and 'timereg' packages.> II. Problem 2: > I try using an example from sourcecode.pdf: > fit <- survfit(Surv(time, status, type=?mstate?) ~ sex, data=mine) > but where can I have the 'mine' data? Thank you!Where do you find 'sourcecode.pdf'? G?ran Brostr?m> > Best, > > Jieyue >
Terry Therneau
2013-Dec-31 22:02 UTC
[R] cumulative incidence for mstate in Survival package in R
Question 1: How to get just 2 cumulative incidence curves when there are multiple covariates. I don't understand what you want. Assume that we have "liver transplant" and "death while waiting for a transplant" as my two events. There are overall curves (2), or one can create curves separately for each sex, or for different institutions. What do you mean by "a curve for age"? If you want competing risks after Cox model adjustment, see the mstate package. Question 2: "mine" data. There is no such data. This was a hypthetical example in the document, and I chose a poor name for the data set; "your_data_set" would have been better. I was using "mine" in the sense of "this data set is mine, it belongs to me", and now see that it could confuse someone. The file sourcecode.pdf is intended to document the computational algorithms, but not how a user would approach the function. A vignette is planned, someday... Terry Therneau On 12/30/2013 04:04 PM, Jieyue Li wrote:> Dear All, > > I want to have the cumulative incidence curves for 'mstate' data using Survival package in > R. But I got some problems: > I. Problem 1: > 1. If I only use intercept without any covariates, I can have 'right' cumulative incidence > curves (2 for 2 competing risks): > library(Survival) > fitCI <- survfit(Surv(stop, status*as.numeric(event), type="mstate") ~ 1,data=mgus1, > subset=(start==0)) > plot(fitCI) > 2. If I include one variate ('sex'), I get 4 curves (attached; I guess because there are > two levels in 'sex' and 2 competing risks): > fitCI <- survfit(Surv(stop, status*as.numeric(event), type="mstate") ~sex,data=mgus1, > subset=(start==0)) > plot(fitCI) > However, I want to just have 2 cumulative incidence curves estimated from several > covariates (such as 'sex', 'age', 'alb', etc. in mgus1). Could you please help me to do > that? Thank you very much! > II. Problem 2: > I try using an example from sourcecode.pdf: > fit <- survfit(Surv(time, status, type=?mstate?) ~ sex, data=mine) > but where can I have the 'mine' data? Thank you! > > Best, > > Jieyue >