adding year to col(gamma) and ext(epsilon) in multiseason occ when we have two years

46 views
Skip to first unread message

Lain E. Pardo

unread,
Jun 20, 2022, 1:27:22 PM6/20/22
to unma...@googlegroups.com

Dear all,

I am playing around with some multi-season occupancy models in Unmarked, but I have this issue. If I used two years (seasons or primary period), when I try to add “year-1” in the colonization and extinction part of the model it does not work, and I received this message.

 m2 <- colext(~1, ~year-1, ~1, ~1, umf)

Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :  contrasts can be applied only to factors with 2 or more levels

I tried exactly the same code but added two fake years more to test the script. So, I used a detection history across four years and all models ran well, including the derived parameters for the projected psi per year.

Is it correct to think that these models only apply to situations where we have more than two years or what can I do to include the year in the col and extinction parameters? (please see below how I added year as a covariate in case it´s wrong)

If I used a model with a covariate only in the initial occ such as m12 <-colext(~Dist.Ele,~1,~1,~1,umf), I can get the col/ext estimates for the first year (and the two years for p) and also the derived estimated occupancy probability for smoothed and projected for each year with their SE (which is actually our primary interest for now). I am just confused about why we can not add the year directly in the col(gamma) and ext(epsilon) part when we have two years (probably more a conceptual question).

Any insight would be highly appreciated.

thanks


All the best

L

--------

A bit of extra context

I created the year cov like this, hope is fine

n <- nrow(sp_DH1)   # number of sites, sp_DH_1 is the detection history df

T <- 2    # number of primary periods, years or seasons

J <- 21    # number of secondary periods (visits per season)

y <- as.matrix(sp_DH1)

 

# create a matrix indicating the year each site was surveyed.

year <- matrix(c('1','2'),  nrow(y), T, byrow=TRUE)


umf <- unmarkedMultFrame( y = y,

               numPrimary = 2, siteCovs = site_covs_s[,11:12], yearlySiteCovs = list(year = year))

*just in case, if I used any other continuos variable in gamma or epsilon it works (e.g. a site covariate that changes between seasons using a list)

--

Postdoctoral Research Fellow

Wildlife Ecology Lab,

School of Natural Resource Management

Nelson Mandela University

George Campus, South Africa

Mobile: +27-0762599325

Colombia: +57-3112538652 (WhatsApp)

Lain....@Mandela.ac.za

Ken Kellner

unread,
Jun 20, 2022, 1:42:03 PM6/20/22
to unmarked
If you have 2 years of data, you are only estimating 1 year of colonization and extinction probabilities (col and ext going from year 1 --> year 2). Thus you would only have a single value in the year factor covariate (year 1), and you can't get a coefficient estimate for a factor covariate with a single level.

unmarked allows you to supply values for all primary periods in the yearlySiteCovs in case you want to use them as part of the detection model, but the final primary period of covariates is automatically dropped from col/ext submodels since it won't be used.

Ken

Lain E. Pardo

unread,
Jun 20, 2022, 2:08:08 PM6/20/22
to unma...@googlegroups.com
Dear Ken, 
thanks for your quick response. That makes sense!


--
*** 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 unmarked+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/unmarked/d2c7b9d7-c243-4ecc-a7d1-5a243514f63dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages