When you post code like that it is much easier for me or anyone else to help if you provide reproducible code. That doesn't mean you need to include the data. For example, I just did the following.
- Code: Select all
time.intervals=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,1,1,1,1,1,1,1)
ch=rep(paste(c("1",rep(c(0,1),14)) ,collapse=""),2)
# get data and add the td time-varying covariate
create.td(ch,begin.time=1988,time.intervals=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,1,1,1,1,1,1,1))
That allows me to understand the problem and what you are saying.
Simple solution here is to remove the following line and then assign the names you want.
- Code: Select all
names(tdmat)=paste(varname,(begin.time+1):(begin.time+nocc-1),sep="")
You could do that manually or create the code that should replace that line.
- Code: Select all
tdmat=create.td(ch,begin.time=1988,time.intervals=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,1,1,1,1,1,1,1))
names(tdmat)
[1] "V1" "V2" "V3" "V4" "V5" "V6" "V7" "V8" "V9" "V10" "V11" "V12" "V13" "V14" "V15" "V16" "V17" "V18"
[19] "V19" "V20" "V21" "V22" "V23" "V24" "V25" "V26" "V27" "V28"
Something like the following or you could spell them out.
- Code: Select all
names(tdmat)=c(paste("td",1988:2008,sep=""),"td2009-2012",...)
Now the issue here is that those will not match the labels for time (as described earlier in posts) unless you change them because it will use intervals like [1989,1990) etc. You can change the labels in the design data. See ?factor in R. But here is a bigger issue to think about. You are using td here to suggest that the probability in year t+1 is affected by capture history in year t. Do you really think that will be the same for year t+4 given year t?
One way around this pickle and it solves your earlier problem is to not have unequal intervals and simply fix p=0 for the years you did not sample. The only tweak you have is to make sure you don't fit time dependent survival without using time intervals such that you assume constant survival during the years in the gap.