I struggle with coding an age-dependent model with 3 age classes and where the animals have been captured in all of these 3 age classes. i.e. they were captured as young, as sub-adult and as adult and pups pass through the age-class pup (0-<1year), then juvenile (1-3years) and then they are considered adult (4 years and older), the juveniles pass only through the stage of juvenile and adult, and adult (obviously) only being adult. The model I aim for beside others is e.g. (Phi(3a-t/t but same for the juveniles of age 1,2 and 3/dot).
At the moment I have that as R code:
- Code: Select all
#create input file
GSL_F_A <- convert.inp("Inputfile_RMark_CJS_marked_p_j_a_02112017.inp", group.df = data.frame(age=c("p","j","a")), use.comments = TRUE)
#Process data
GSL_F_A.process <- process.data(GSL_F_A,model="CJS", groups="age", initial.age=c(4,1,0),begin.time=2003)
#create design data
GSL_F_A.ddl=make.design.data(GSL_F_A.process)
#add age classes
GSL_F_A.ddl=add.design.data(GSL_F_A.process, GSL_F_A.ddl,parameter="Phi", type="age", bins=c(0,1,4,18),name="ageclass", right=FALSE)
#Add dummy variables: marked as pup (1, 0), marked as juvenile (0, 1), marked as adult (1,1)
GSL_F_A.ddl$Phi$marked.as.pup=0
GSL_F_A.ddl$Phi$marked.as.pup[GSL_F_A.ddl$Phi$group!="j"]=1
GSL_F_A.ddl$Phi$marked.as.juvenile=0
GSL_F_A.ddl$Phi$marked.as.juvenile[GSL_F_A.ddl$Phi$group!="p"]=1
#for p
GSL_F_A.ddl$p$marked.as.pup=0
GSL_F_A.ddl$p$marked.as.pup[GSL_F_A.ddl$p$group=="p"]=1
# set up models
GSL_F_A.models=function() { Phi.ageclass.time.plus.marked.as.adult=list(formula=~ageclass*time+marked.as.pup+marked.as.juvenile)
Phi.ageclass.time=list(formula=~ageclass*time)
p.marked.as.adult=list(formula=~marked.as.pup)
cml=create.model.list("CJS")
results=mark.wrapper(cml,data=GSL_F_A.process,ddl=GSL_F_A.ddl,output=FALSE)
return(results) }
ageclass.results=GSL_F_A.models()
ageclass.results
I think my dummy definition of marked as pup, juvenile and adult might cause some trouble. I also don't know how to implement that the juveniles of 1, 2 and 3 don't differ in the survival.
Any hints are appreciated, thanks a lot!