Set initial age withouth group

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

Set initial age withouth group

Postby omira » Tue Oct 11, 2016 9:11 pm

Hi all,
I'm analycing some data with R.mark and I'll like to find a better solution for dealing with the age groups
My data originally was like this

Code: Select all
ch   Fem   Mal   Span
1000   0   1   0
1010   0   1   0
1000   0   1   1
1000   1   0   0
1000   0   1   2
1001   1   0   1


Where Fem and Mal are the sex of the individuals and Span is the initial age class of release for each individual
Span levels go from 0 to 3

I started analysing it as a group and a covariate

Code: Select all
jsexspanc.convert=convert.inp("Jsexspanc.inp", group.df= data.frame(sex=c("Male", "Female")), covariates="Span", use.comments=TRUE)


But after checking my old notes on the markbook and some workshops I found online, I realised a better way to deal with the initial age, so I transformed the input file:

Code: Select all
ch   Fe0   Fe1   Fe2   Fe3   Ma0   Ma1   Ma2   Ma3
1000   0   0   0   0   1   0   0   0
1010   0   0   0   0   1   0   0   0
1000   0   0   0   0   0   1   0   0
1000   1   0   0   0   0   0   0   0
1000   0   0   0   0   0   0   1   0
1001   0   1   0   0   0   0   0   0


So now we have one group for each combination of sex and initial age.
Then I proceed the model design

Code: Select all
jrestall8g.convert=convert.inp("jrestall8g.inp", group.df=data.frame(sex=c("Female", "Female", "Female", "Female", "Male", "Male", "Male", "Male"), span=c("Fresh", "Good", "Old", "Worn", "Fresh", "Good", "Old", "Worn")))
str(jrestall8g.convert)
jrestall8g.convert


(I named the four levels of span like this, so they conserve the same order when in alphabetical order)
Then

Code: Select all
jrestall8g.proc=process.data(jrestall8g.convert, begin.time=110703, model="POPAN", groups=c("sex", "span"), age.var=2, initial.ages=c(0,1,2,3), time.intervals=c(3,3,2))
str(jrestall8g.proc)
jrestall8g.proc
jrestall8g.ddl=make.design.data(jrestall8g.proc)

I think I got exactly the initial dates and age that I was looking for, in the future I may use add.design.data to bin age in four intervals.

The problem is that I don't really want to analyse and get the estimates of all the parameters, separately for each of the 8 groups
I will like to set the initial ages for each individual and to include the covariate in the model (To test if a model with Phi(span) is better than one with Phi(time)) but get the estimates for all the individuals of each sex (2 groups), not for each combination of sex and "span" (8 groups).
Does this makes sense or I am too tired? Is it possible to treat "span" as a covariate, but somehow add it as a initial age?

Thank you for your time.
omira
 
Posts: 5
Joined: Tue Oct 11, 2016 8:25 pm
Location: Sheffield, Valencia and Granada

Re: Set initial age withouth group

Postby jlaake » Wed Oct 12, 2016 11:15 am

If you wanted to deal with groups, you made it too difficult for yourself. You could have kept it in the original format of ch Fem Mal Span and then used

Code: Select all
jsexspanc.convert=convert.inp("Jsexspanc.inp", group.df= data.frame(sex=c("Male", "Female")), covariates="Span", use.comments=TRUE)
dp=process.data(jsexspanc.convert,groups=c("sex","Span"),age.var=2,initial.ages=c(0,1,2))


Note, in the example there were only 3 span values so I used that to test. If there are 4 then you would give 4 initial.age values. I'm not sure why you thought you needed to convert the way you did. Maybe lack of sleep as you implied. What you did was to turn all of the groups into 0/1 dummy variables.

If you have as groups you can always get the N values by group and sum for say M and F. The variance is simply the sum of the variance-covariance matrix elements for each set.

But if you want to go the covariate route, then you need to convert age to a time varying individual covariate. For each individual you would have AGE1,AGE2,AGE3,AGE4 which is the age of the animal at each of the 4 occasions. I used AGE capitalized so it will not get confused with age and Age in the desig data. Then you can use AGE in the formula for Phi or p, although I'm not sure how you are going to handle AGE<0. I would set them to 0 if <0 but the problem is that p should be 0 for occasions prior to when they were alive in the POPAN model. If you are only interested in survival then use CJS and this is not a problem because it is conditional on first release.

If you are trying to estimate abundance with POPAN, stick with groups defined by Span because you can fix parameter p=0 for occasions before the animal was alive. If you do that you also have to have groups defined by Span as defined by the first occasion such that each group has the same age structure across all occasions. Essentially you are grouping by birth cohorts and estimating the N for age 0,1,2,3 etc for each cohort.

Hope this makes sense. --jeff
jlaake
 
Posts: 1479
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Set initial age withouth group

Postby omira » Thu Oct 13, 2016 7:58 pm

It totally makes sense.
I'm using POPAN because I'm indeed interested in the abundance.
I think I'll try both approaches with this population to check which one is more straight forward and decide which one makes more sense (and less effort) to apply to all the other populations.

With the covariate approach, as far as I understand (not very far) if I change the Span ages from 0-3 to 1-4; and then set to 0 if <0 (as you said) it should work. If I have any problem with this I will probably take the "group" approach.

Thanks for your answer

-Óscar (1:56 am; I'm going to sleep now)
omira
 
Posts: 5
Joined: Tue Oct 11, 2016 8:25 pm
Location: Sheffield, Valencia and Granada

Re: Set initial age withouth group

Postby jlaake » Thu Oct 13, 2016 8:19 pm

Best to do on a good night rest.

You can only use the covariate approach if you are NOT interested in abundance. If you want abundance, I suggest reading the Jolly-Seber chapter in Cooch and White and see if they cover age-structured populations.

If you use birth cohort groups like I suggest then you can set p=0 for occasions prior to when the individuals were alive.
jlaake
 
Posts: 1479
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Set initial age withouth group

Postby omira » Wed Oct 19, 2016 10:40 pm

Yes, I did read that chapter some time ago, but just now (thanks!) I realised the version I had of the Markbook was outdated. I started trying to use POPAN because the salmonid example works indeed with different age groups. Now I realised that it clearly explains at the end of the chapter to not use individual covariates, but after your answers that was already out of question.

Using the approach suggested gave me an "is not a factor variable. Coercing to factor" error, so I did this

Code: Select all
jsexspanc.convert=convert.inp("Jsexspanc.inp", group.df= data.frame(sex=c("Male", "Female")), covariates="Span.n", use.comments=TRUE)
Span <- factor(jsexspanc.convert$Span.n, labels = c("fresh", "good", "old", "worn"))
#the experiment was performed 03-07-2011; 06-07-2011; 09-07-2011 and 11-07-2011
jsexspanc.proc=process.data(jsexspanc.convert,groups=c("sex","Span"),age.var=2,initial.ages=c(0,1,2,3),begin.time=110703, model="POPAN", time.intervals=c(3,3,2))
jsexspanc.ddl=make.design.data(jsexspanc.proc)
jsexpanc.ddl


So far the data seems OK (not the N values, but I will guess is because of the p < 0 issue).
I'll set any age above 5 as 5 in the future, but now I'm dealing with fixing the value of p=0; I read the two threads about this in this forum, but I don't need to fix the p of a specific time (day), so things like this will not help:
Code: Select all
jnazisexspanc.ddl$p$fix=NA
jnazisexspanc.ddl$p$fix[jnazisexspanc.ddl$p$time==110703]=0


How do I fix it for "before they were alive"?

<We wrote down the "age groups" (Span), because we work with butterflies, and the adults fly for a really short period of time; it was a way of check if the experiment was done in the peak of the mating season, or at the beginning, or end of it. Now I'm starting to consider not introducing the "Span" group of ages, as it seems to be complicating the formulation too much and I don't want to be a pain in the ass here all the nights that I got time to work on this.>

And thanks a lot for the feed-back!

-Óscar (4:38 am; edited at 12.40 pm)
omira
 
Posts: 5
Joined: Tue Oct 11, 2016 8:25 pm
Location: Sheffield, Valencia and Granada

Re: Set initial age withouth group

Postby jlaake » Mon Oct 24, 2016 6:33 pm

You are not quite getting what I mean by birth cohorts. You need to identify the occasion at which they could enter the population and then group all the individuals together that could enter on the same occasion into a "birth cohort" and use that variable as your group variable. You need to use Span to define the cohorts but can't use Span as the grouping variable.

For example, let's say your occasions are days and on day 1 you had some animals that were one day old (Span=1?). Then on day 2 you caught some that were 2 days old (span=2?) that weren't seen on day 1. Then on day 3 you caught some that were 3 days old that had not been seen the prior 2 days, etc. These would all be in the same birth cohort 1 because they all could have been seen on day1 - some were and some were not. Then you do the same for birth cohort 2 etc. Now I have no idea whether this is possible because I'm not sure I understand your span variable and don't know anything about butterflies. If you can't do that then you can't do what I was talking about. If you can then you are good.

Below is a dummy example using the dipper data. Here they all are seen entering on "birth day" for the first time but not after. So not a good example that way but it shows how you can setup like I was talking about to fix p=0 for occasions before they can be seen.


Code: Select all
data(dipper)
# create a cohort variable - occasion first entered
dipper$cohort=sapply(strsplit(dipper$ch,""), function(x){
 z=as.numeric(x)*(1:7)
 z=z[z>0]
 min(z)})
dipper$cohort=factor(dipper$cohort)
dp=process.data(dipper,model="POPAN",groups="cohort")
ddl=make.design.data(dp)
ddl$p$Cohort=as.numeric(ddl$p$cohort)
# fix p=0 for any occasion prior to when the cohort could possibly be seen (before it was born)
ddl$p$fix=ifelse(ddl$p$Time<ddl$p$Cohort,0,NA)

Again I reiterate that you should read the POPAN chapter to see if this is discussed. I'm leading you based on my intuition and I could be wrong. You may want to post a generic question about estimating abundance using age structure.
jlaake
 
Posts: 1479
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Set initial age withouth group

Postby omira » Tue Oct 25, 2016 8:37 am

OK. You are right I was not getting it. Thanks for he detailed explanation.
Now that I understand it, I think I can not do what you suggest.

The Span covariable (it is a bad name) is a measure of how "wasted" the butterflies are when we capture them. We are sure this affects their life span and it's affected by the time, but also by the weather and individual story. So when we classify a individual as "fresh", I'm sure it has just a few hours, and when I classify an individual as "worn", it means it has been flying for long, has the wings broken, and it will probably die soon. But this doesn't mean that a butterfly caugt in the second day and classified as "good" (1) is from the same cohort that one caught the first day and classified as "fresh" (0). With the recaptures we have checked that some butterflies take a couple of days to pass from fresh to good, while others may take till four days.

I still think it is interesting to see if the models including this information are better supported that the others and if it affects survival.

I guess I will follow your suggestion and ask in the general MARK forum if anyone has an idea of how to use this variable in a POPAN (or other) model to estimate abundance. Or else I may run a CJS model with Span (just to check) and calculate abundance with POPAN without Span.

The good thing about RMark is that I can keep working without it and at the end if I manage to include it I just need to change a few lines in the code.

Thanks again!
omira
 
Posts: 5
Joined: Tue Oct 11, 2016 8:25 pm
Location: Sheffield, Valencia and Granada


Return to RMark

Who is online

Users browsing this forum: No registered users and 0 guests