I am learning RMARK and finding it tricky to translate the examples in Appendix C and RMARK workshop notes to my situation with 3 age groups. I currently have sub adult birds "young" (aged 0.5-1.5 yrs), "middle" aged birds (2 to 3.5 years) and "old" birds (4 to 16). In order to have a full age*time interaction for each group (and constant survival for some age classes but time interaction for others) I have tried setting up dummy variales for each age group, but then when I come to building the models I get an error saying that the object "middle" can't be found... etc. I am not sure what I am doing wrong with coding these age groups dummy variables, but would very much appreciate some guidance on this. I have pasted in the code I have so far below and hope someone can help.
Thanks!
- Code: Select all
#####Create processed data list. Type = CJS. time interval is 6 monthly =rep(1,32).
#Initial age is 6 months (=0.5) begin.time=1 specifies start point.
#The age.unit is 6 months (=0.5)
IAAAGE2.process=process.data(IAAAGE2,model="CJS",time.intervals=rep(1,32),initial.age=0.5,begin.time=1,age.unit=0.5)
#make default design data:
IAAAGE2.ddl=make.design.data(IAAAGE2.process)
#add a young/middle/old age field to the design data for Phi named YMO
IAAAGE2.ddl=add.design.data(IAAAGE2.process,IAAAGE2.ddl,"Phi","age",bins=c(0.5,2,4,16),right=FALSE,name="YMO")
#Add a field to the design data that is equivalent except it is a numeric dummy coding variable 1. 1st = young
IAAAGE2.ddl$Phi$young=0
IAAAGE2.ddl$Phi$young[IAAAGE2.ddl$Phi$age=="[0.5,2)"]=1
#then add field for middle age class
IAAAGE2.ddl$Phi$middle=0
IAAAGE2.ddl$Phi$middle[IAAAGE2.ddl$Phi$age=="[2,4)"]=1
#then add old age class
IAAAGE2.ddl$Phi$old=0
IAAAGE2.ddl$Phi$old[IAAAGE2.ddl$Phi$age=="[4,16]"]=1