pooling time intervals

posts related to the RMark library, which may not be of general interest to users of 'classic' MARK

pooling time intervals

Postby bvernasco » Fri Jun 19, 2015 12:38 pm

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?
bvernasco
 
Posts: 4
Joined: Sat Jun 06, 2015 4:14 pm

Re: pooling time intervals

Postby jCeradini » Sat Jun 20, 2015 11:23 am

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
jCeradini
 
Posts: 74
Joined: Mon Oct 13, 2014 3:53 pm

Re: pooling time intervals

Postby jlaake » Sat Jun 20, 2015 5:09 pm

Look at help for cut function in R ?cut it will do what you want.
jlaake
 
Posts: 1480
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA


Return to RMark

Who is online

Users browsing this forum: Google [Bot] and 3 guests