[R] cumulative incidence for mstate in Survival package in R

Göran Broström goran.brostrom at umu.se
Wed Jan 1 00:52:20 CET 2014



On 12/31/2013 09:05 PM, Jieyue Li wrote:
> Thanks a lot for the reply!
>
> On Tue, Dec 31, 2013 at 1:59 AM, Göran Broström <goran.brostrom at umu.se
> <mailto:goran.brostrom at umu.se>> wrote:
>
>     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;)
>
> This is from an example from the Survival package...

Sorry; the problem is that 'survival' should be with lower-case 's'

>
>
>         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'?
>
> It's from
> http://stat.ethz.ch/R-manual/R-patched/library/survival/doc/sourcecode.pdf

I see; that is a generic example, I suppose. The data set 'mine' is one 
of your choice! But, as I suggested, look into the packages listed under 
'Multistate models' in 'Survival' under 'Task Views'. What you ask for 
cannot be accomplished with the package 'survival'.

Göran Broström

>
>     Göran Broström
>
>
>         Best,
>
>         Jieyue
>
>
>     ________________________________________________
>     R-help at r-project.org <mailto:R-help at r-project.org> mailing list
>     https://stat.ethz.ch/mailman/__listinfo/r-help
>     <https://stat.ethz.ch/mailman/listinfo/r-help>
>     PLEASE do read the posting guide
>     http://www.R-project.org/__posting-guide.html
>     <http://www.R-project.org/posting-guide.html>
>     and provide commented, minimal, self-contained, reproducible code.
>
>



More information about the R-help mailing list