Page 1 of 1

Age bins - teething problems

PostPosted: Wed Jun 05, 2013 11:58 am
by Lconcannon
Hi
I am learning RMark. For my current analysis I am trying to create age bins using add.design.data to compare models with different age class structures for Phi. It is a 16 year data set, the time interval is 6 months, initial age is 0.5. I get the error message:
"Error in make.mark.model(data.proc, title = title, parameters = model.parameters, :
Problem with design data. It appears that there are NA values in one or more variables in design data for Phi
Make sure any binned factor completely spans range of data"

I have checked the problem area indicated in the error message but cannot figure out what I have done wrong. As far as I can tell, the age bins I have set up do span the range of data.

The code i have used is embedded below - hope someone can point me in the right direction and let me know what I am getting wrong here. Many thanks!

Code: Select all
IAAAGE1.process=process.data(IAAAGE1,model="CJS",time.intervals=rep(1,32),initial.age=0.5,begin.time=1,age.unit=0.5)
#make default design data
#
IAAAGE1.ddl=make.design.data(IAAAGE1.process)
IAAAGE1.ddl$Phi
IAAAGE1.ddl$p
#Add design data. Define a number of different design data lists to compare models with diff age bin classes
#
IAAAGE1.ddl=add.design.data(IAAAGE1.process,IAAAGE1.ddl,parameter="Phi",type="age",bins=c(1,2,32),name="ageclass1",right=FALSE)
IAAAGE1.ddl=add.design.data(IAAAGE1.process,IAAAGE1.ddl,parameter="Phi",type="age",bins=c(1,3,32),name="ageclass2",right=FALSE)
IAAAGE1.ddl=add.design.data(IAAAGE1.process,IAAAGE1.ddl,parameter="Phi",type="age",bins=c(1,4,32),name="ageclass3",right=FALSE)
IAAAGE1.ddl=add.design.data(IAAAGE1.process,IAAAGE1.ddl,parameter="Phi",type="age",bins=c(1,5,32),name="ageclass4",right=FALSE)
IAAAGE1.ddl=add.design.data(IAAAGE1.process,IAAAGE1.ddl,parameter="Phi",type="age",bins=c(1,4,20,32),name="ageclass5",right=FALSE)
#
#Earlier analysis showed that P should be constant.
#
do.analysis=function()
{
  Phi.time=list(formula=~time)
  Phi.dot=list(formula=~1)
  Phi.ageclass1=list(formula=~ageclass1)
  Phi.ageclass2=list(formula=~ageclass2)
  Phi.ageclass3=list(formula=~ageclass3)
  Phi.ageclass4=list(formula=~ageclass4)
  Phi.ageclass5=list(formula=~ageclass5)
  p.dot=list(formula=~1)
  #use create model list (CML) to construct the combinations of models and store in cml object
  cml=create.model.list("CJS")
  #use mark.wrapper to fit each model in mark
  model.list=mark.wrapper(cml,data=IAAAGE1.process,ddl=IAAAGE1.ddl)
  #Return the list of model results as the value of the function
  return(model.list)
}
  #Run analysis by assigning it to object:
  IAAAGE1results=do.analysis()
  #
  #Show results
  IAAAGE1results

Re: Age bins - teething problems

PostPosted: Thu Jun 06, 2013 9:15 am
by jlaake
You have set initial.age=0.5, so the value for Phi is 0.5 for the initial time interval but the age bins you specified started at 1 so it will not include 0.5. If you typed IAAAGE1.ddl$Phi you would have seen the NA values for ageclass1, etc.

--jeff

Re: Age bins - teething problems

PostPosted: Mon Jun 10, 2013 6:46 am
by Lconcannon
Thanks Jeff, I realise I was using the time intervals not age categories for the bins, thanks for pointing that out!!
Lianne