Page 1 of 1

Time varying covariate in known fate model

PostPosted: Wed Apr 03, 2019 1:37 pm
by mconner
I am trying to build a simple known fate model with season; there are 3 seasons a year and the input file has 14 seasons. All works fine until I specified the unequal time intervals, after which I get the message:

ESMD_S.ddl$S=merge_design.covariates(ESMD_S.ddl$S, dfseason1)
Error in merge_design.covariates(ESMD_S.ddl$S, dfseason1) :
dfseason1 does not contain a time value for each time in design data

There are 3 groups, the code I am using is below. I've tried some different begin.time=, but to no avail.

Thanks for your help. Mary
************************************************************************************************
ESMD_S.process=process.data(ESMD_S,groups="herd",model = "Known", time.intervals=c(0.975,1.238,0.959,0.959,1.066,0.615,1.246,1.328,0.525,1.156,1.213,0.713,1.041,1.451))
ESMD_S.ddl=make.design.data(ESMD_S.process)

dfseason1=data.frame(time=c(1:14),season1=c(1,0,0,1,0,0,1,0,0,1,0,0,1,0))
ESMD_S.ddl$S=merge_design.covariates(ESMD_S.ddl$S, dfseason1)

Re: Time varying covariate in known fate model

PostPosted: Wed Apr 03, 2019 5:36 pm
by jlaake
The time values in dfseason1 are 1 to 14 but with unequal intervals they aren't integer values. Look at the time values in the design data and use those in dfseason1$time. That function is using merge which is like a join and field values have to match.

Re: Time varying covariate in known fate model

PostPosted: Thu Apr 04, 2019 1:47 pm
by mconner
Thank you Jeff! Sometimes I just need a knock on the head. I had tried what you suggested already (incorrectly) and it didn't work. BUT, this morning, after re-reading your email I realized time is cumulative in the design data, so I had to ADD my unequal time intervals, and not just paste them is as they were.

Mucho gracias. Mary