Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205301

competing risks in R

$
0
0

Here another newbie question in R

I have three vectors of censored times, each for a specific cause of censoring.

X0<-rexp(400,2)
X1<-rexp(400,5*exp(log(0.5)*data$main_exposition)) 
X2<-rexp(400,3)
X3<-rexp(400,4)

I want to merge them in a unique vector representing each event 1,2,3 for respectively X1,X2,X3 and non informative censoring 0 for X0. The main exposition (treatment 1:receiving treatment vs 0)has an effect only on X1 which is the event of interest.

data<-data.frame(main_exposition=sort(rep(0:1,200)))
table(data$main_exposition)

0   1 
200 200 

I found this method which seems working but I would like to understand why is there -1 at the end of apply()?

data$D<-apply(cbind(X0,X1,X2,X3),1,which.min)-1

Thank you for your help


Viewing all articles
Browse latest Browse all 205301

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>