Dummy variables for 3 age groups

posts related to the RMark library, which may not be of general interest to users of 'classic' MARK

Dummy variables for 3 age groups

Postby Lconcannon » Wed Jun 19, 2013 8:14 am

Hi
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
Lconcannon
 
Posts: 12
Joined: Wed Feb 06, 2013 6:35 am

Re: Dummy variables for 3 age groups

Postby jlaake » Wed Jun 19, 2013 10:55 am

To make sure I understand, your time intervals are set to 1 so your survival will be 1/2 year survival rate, correct?

Did you look at the design data

summary(IAAAGE2.ddl$Phi)

From the code you gave, what you'll see is that your binned data for age is in "YMO" which is the name you gave it in the call to add.design.data. You didn't bin the age column which is what you are using in the if statements to define the other variables. Whenever, you get an error like this or even before you get an error, look at the design data to make sure it is setup as you expect. Treat it like any other source of data. If it isn't correct, your model will not be correct.

regards--jeff
jlaake
 
Posts: 1479
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Dummy variables for 3 age groups

Postby Lconcannon » Sat Jun 22, 2013 2:30 pm

Hi
Thanks for the reply. Yes, I have 6-monthly intervals here.
Just to check that I haven't misunderstood, should I use "YMO" where I have written "age" in the dummy variable code? I still can't seem to get it to work having tried that just now. I have read everything I can find on similar examples and can't seem to get it working.
Appreciate the help!
Thanks
Lconcannon
 
Posts: 12
Joined: Wed Feb 06, 2013 6:35 am


Return to RMark

Who is online

Users browsing this forum: No registered users and 1 guest