grouped age cov in openCR

questions concerning anlysis/theory using program DENSITY and R package secr. Focus on spatially-explicit analysis.

grouped age cov in openCR

Postby mgm5568 » Wed Nov 22, 2023 3:17 pm

Hi all,

I am trying to fit a nonspatial (PLBl) model with an age covariate for an analysis using eastern redbacked salamanders. Ultimately, the goal is to fit a PLBsecrl model, but I am having issues with some of the covariates. The study contains 19 sessions with 9 occasions each. Each session represents a spring (March-May) and fall (Sept-Nov) survey season since our species has 2 peak activity windows each year. Ideally, the dataset has 3 age groups (hatchling/juvenile = 0, subadult = 1, adult = 2). I want to group the ages so that it takes 2 years (4 sessions) for a juvenile to reach the adult stage. I created an initialage covariate which is the age of each individual when we catch it for the first time, and it can therefore equal 0, 1, 2, 3 or 4. A printed subset of my data is below:

Code: Select all
print(captures)
Session         ID Occasion Detector sex initialage
1         1    OxxO_CH        1       D9   F          4
2         1    OxxO_CO        1       B3   U          4
3         1    OxxR_CH        1      C10   F          2
4         1    OxxY_CO        1       A4   U          2
5         1    RxxO_CH        1       C7   U          2
6         1    RxxR_CH        1       D5   U          3
7         1    xBOx_CH        1       C3   M          4
8         1    xBRx_CH        1      E10   F          4
9         1    xBxB_CH        1      D10   F          4
10        1    xBxO_CH        1      B10   U          4
11        1    xBxR_CH        1       E2   F          4
12        1    xxBB_CH        1       D2   U          1
13        1    xxBO_CH        1       D8   M          4
14        1    xxBR_CH        1       A9   M          4
15        1    xxBx_CH        1       C5   F          4
16        1    xxBx_CO        1       A3   M          4
17        1    xxOx_CH        1       B8   F          4
18        1    xxOx_CO        1       C7   U          4
19        1    xxRx_CO        1       B6   F          4
20        1   xxRx_ECO        1       E3   U          1


Based on the age.matrix (below), it seems that age increases with each session.

Code: Select all
age.matrix(join(rbsCH, initialage = initialage, maximumage = 4, collapse = TRUE)
BBBB_CO     "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111222222222333333333444444444444444444444444444444444444444444444444444444"
BBBB_ECO    "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111222222222333333333444444444"
BBBB/B_CO   "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111222222222"
BBBBOx_CH   "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111222222222333333333444444444444444444"


However, because I it takes 2 years (4 sessions) for a juvenile to reach the adult stage, I want salamanders aged 0-1 to be grouped as 0, salamanders aged 2-3 to be grouped as 1, and salamanders aged 4 to be grouped as a 2. I therefore passed the c(0,0,1,1,2) to the agecov argument in openCR.fit() based on the openCR.design helpfile (below):
agecov may be used to group ages. It should have length (or number of rows) equal to maximumage + 1.


Code: Select all
nonspRBSage <- openCR.fit(rbsCH, type = 'PLBl',
                          agecov = c(0,0,1,1,2),
                          details = list(initialage = initialage,
                                         maximumage = 4),
                          model = list(p~age, phi~1), ncores = 8)


When I run this model, I get output, but I also get this error message

Error in stdcovlist(object$agecov, "acov", nstrata, diff(agerange) + 1) :
number of covariate values differs from expected in one or more strata.


Similarly, the beta (and real parameter) estimates suggest that the ages are not grouped as I would expect:
Code: Select all
Beta parameters (coefficients)
               beta    SE.beta          lcl          ucl
p      -11.21614114 0.20254303 -11.61311819 -10.81916409
p.age1   6.03419297 0.20033012   5.64155315   6.42683279
p.age2   6.86335271 0.20033178   6.47070963   7.25599578
p.age3   6.92915819 0.20860411   6.52030164   7.33801474
p.age4   8.83266351 0.20458217   8.43168983   9.23363719
phi      0.01399294 0.04151103  -0.06736718   0.09535306
lambda  -1.28406484 0.00000000  -1.28406484  -1.28406484


I have looked through the openCR pdfs and secr pdfs for a worked example of a time-varying individual covariate, but I have not had any luck. Does anyone know if one exists? Any help would be appreciated.
mgm5568
 
Posts: 2
Joined: Tue Nov 21, 2023 11:35 am

Re: grouped age cov in openCR

Postby murray.efford » Wed Nov 22, 2023 9:54 pm

Hi.
It may take me a few days to dig into this. It would help if you are able to send example data and code offline.
Murray
murray.efford
 
Posts: 712
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: grouped age cov in openCR

Postby murray.efford » Thu Nov 30, 2023 4:16 am

Hello Maisie

Thanks for sending your data offline. I'm not sure exactly what was going wrong.

Age is not a time-varying covariate in the usual sense because it advances at a predictable rate and therefore if known initially it is known at every sampling occasion. The 'agecov' grouping mechanism of earlier versions is deprecated in the just-released version openCR 2.2.6. Now you should specify the details argument 'agebreaks' (example in new vignette). This takes account of the actual intervals between sessions, rather than assuming age increased by 1.0 at each session.

This works for me:

agefit <- openCR.fit(rbsCH, type = 'CJS', model = list(p~1, phi~age), ncores = 8,
details = list(initialage = initialage, maximumage = 2, agebreaks = c(0,1,2,Inf)))
predict(agefit, all = TRUE)

I am starting with a CJS model that does not attempt to handle recruitment: it's simpler initially to dodge issues that come from fixing recruitment. Age increases with the cumulative sum of the intervals, and I assume your intervals (coded in your capthist object, but not visible here) are in years, hence 0, 1, 2, Inf.

A detail: you may have misinterpreted 'intervals'; these run from the start of one session to the start of the next, and so over your 19 6-monthly sessions should add to about 18 x 0.5 = 9 years. For yours I get sum(intervals(rbsCH)) = 7.671233.

Also, I expect you will have trouble modelling such a large dataset. It may help to collapse observations within sessions to a single 'occasion' (secr::reduce(CH, by = 'all', outputdetector = 'count'), or even outputdetector = 'proximity' sacrificing some within-session recaptures). That is technically incorrect for multi-catch detectors (perhaps these are cover boards?) but I expect the damage is minor.

Murray
murray.efford
 
Posts: 712
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: grouped age cov in openCR

Postby mgm5568 » Thu Feb 15, 2024 12:01 pm

Dear Murray,

Thank you so much for your help. Apologies for the delay, I don't know why I was expecting an email rather than a forum reply.

Thank you for the clarification on time-varying covariates. The new agebreaks argument in details works for me as well.

Thank you pointing out the misinterpretation of 'intervals'. I get a sum of about 8.9 now, which follows based on your explanation. And we will keep your suggestion about collapsing observations in case we run into processing time issues.
mgm5568
 
Posts: 2
Joined: Tue Nov 21, 2023 11:35 am

Re: grouped age cov in openCR

Postby murray.efford » Thu Feb 15, 2024 4:19 pm

I'm glad that worked for you. I'm surprised you didn't get email notification of my original reply - perhaps its worth checking settings under User Control Panel | Board preferences?
murray.efford
 
Posts: 712
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand


Return to analysis help

Who is online

Users browsing this forum: No registered users and 1 guest