Page 1 of 1

pooling time intervals

PostPosted: Fri Jun 19, 2015 12:38 pm
by bvernasco
Hi guys, I am currently running a known fate model in RMark and need to pool some time intervals such that the survival estimates are blocked together between groups of intervals. I could see how this could easily be done in MARK using the design matrices and I think I have an understanding of how to do this in RMark. However, I want to confirm my script to make sure I am doing it right.

So, in this example, I have 48 encounter occasions and want to combine the following intervals:

1-4,5-8,9-15,16-48

To do this I wrote the following code:

data.process<-process.data(data, model="Known", groups="Year")

data.ddl<-make.design.data(data.process)

data.ddl$S$timefour=facotr(c(1,1,1,1,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4))

Is this code correct?

Re: pooling time intervals

PostPosted: Sat Jun 20, 2015 11:23 am
by jCeradini
This may work:

Code: Select all
data.ddl$S$NewTime <- NA

data.ddl$S$NewTime[data.ddl$S$OldTime %in% c(1:4)] <- 1
data.ddl$S$NewTime[data.ddl$S$OldTime %in% c(5:8)] <- 2
data.ddl$S$NewTime[data.ddl$S$OldTime %in% c(9:15)] <- 3
data.ddl$S$NewTime[data.ddl$S$OldTime %in% c(16:48)] <- 4

Then call NewTime in your formula.

Joe

Re: pooling time intervals

PostPosted: Sat Jun 20, 2015 5:09 pm
by jlaake
Look at help for cut function in R ?cut it will do what you want.