How to allow detection to vary between years without specifying a covariate_colext_dynamic occupancy

Skip to first unread message

James Shelley

Sep 21, 2023, 7:30:11 AM9/21/23
to unmarked

First of all, thank you for this package and your continuous support.

My question is simple, but I'll provide some context in case you have any further advice to give (skip to the red text below if you want to save time). 

I have a question relating to a multi-year fish presence/absence dataset. I have 39 years of data collected over the management area of a large city that has ~30 river basins. Think of it a bit like a citizen science database or something like that. The data was collected using every method known to fish ecologists, but the methods were always effective ones. Sampling was not spatially or temporally consistent within river basins, but non the less I've combined all observations within each river basin for each year. In the dynamic occupancy model I am using each year of data as secondary surveys (replicates) and three years are combined to make one primary sampling occasion (13 primary sampling occasions over 39 years).

The species I'm interested in (one species at a time) are migratory and spawn in response to Autumn and Spring freshes (small floods). Flows in most of the river basins are regulated and historically the magnitude of Autumn and Spring freshes has been impacted. Efforts have been made to rectify this situation over the last couple of decades though and the expectation is that these species have benefited. 

I'd like to see if the percentage of days where Autumn and Spring freshes have occurred in each primary sampling period relate to changes in each species' occupancy. 

It's all a bit rough around the edges, but I think it could work well enough if the patterns are strong and the interpretation is appropriate. 

My question relates to the detection probability. As the data was collected with multiple methods, at multiple times of the year, from multiple people, I don't want to relate it to any environmental variables. I just want it to vary between years without relating it to a observation covariate. How do I write that in the equation? If ~1 is constant between years and ~observation covariate has it varying between years and relating the variation to the variable, what is the formula for just varying between years? 

I've provided a basic example below.. 

dynamic_occ_m1 <- colext(
  # Psi depends on initial Autumn flow conditions
  psiformula = ~AutumnFlow1,
  # colonization depends on change in Autumn flow conditions
  gammaformula = ~autumflow_time,
  # extinction  depends on change in Autumn flow conditions
  epsilonformula = ~autumflow_time,
  # I don't want detection to depend on anything. I want it to vary through time as per it's base calculation
  pformula = ~?,
  # data must be a unmarkedMultFrame
  data = Tupong_unmarkedMultFrame,
  # method is optim method, leave as "BFGS"
  method = "BFGS")

Thanks in advance for your time. It's much appreciated.


James Shelley

Sep 25, 2023, 7:37:23 AM9/25/23
to unmarked

I'm just following up on this. I'd really appreciate the help.


Marc Kery

Sep 25, 2023, 7:58:57 AM9/25/23
Dear James,

you must define 'Year' as a so-called yearly site covariate. I.e., for (hypothetical) 4 sites and 3 years, you create a structure like this:

1 2 3
1 2 3
1 2 3
1 2 3

You will fit into the umf() data-frame-creation function in the right way and can then specify it as a covariate in p. You can see that in the examples of the colext help, especally also about the specific format.

IF you know which datum (= actual observation) was produced by which method, you may in addition code for 'Method' as a so-called observational covariate (actually, a factor) and could then specify a model for p that looks like ~ Year + Method.

Best regards  --- Marc

From: <> on behalf of James Shelley <>
Sent: Monday, September 25, 2023 13:37
To: unmarked <>
Subject: [unmarked] Re: How to allow detection to vary between years without specifying a covariate_colext_dynamic occupancy
*** Three hierarchical modeling email lists ***
(1) unmarked (this list): for questions specific to the R package unmarked
(2) SCR: for design and Bayesian or non-bayesian analysis of spatial capture-recapture
(3) HMecology: for everything else, especially material covered in the books by Royle & Dorazio (2008), Kéry & Schaub (2012), Kéry & Royle (2016, 2021) and Schaub & Kéry (2022)
You received this message because you are subscribed to the Google Groups "unmarked" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

James Shelley

Sep 25, 2023, 6:36:36 PM9/25/23
to unmarked
Thanks very much Marc. That's worked well. Thanks again.


Reply all
Reply to author
0 new messages