prediction with random effects in Nmix model

50 views
Skip to first unread message

Marc Kery

unread,
May 15, 2024, 7:35:25 AMMay 15
to unmarked, ahavard....@gmail.com, Nicolas Strebel

Dear all,

 

Antoine Havard, Nicolas Strebel, and I have been fitting N-Mixture models using pcount() to multi-year data in the stacked data format. Our main interest is the trajectory of abundance over time (1999–2021). To account for possible dependence in the data across years, we fit random effects for the 267 sites. Now, when using predict() to produce year-specific estimates of lambda, we got stuck because we didn't understand how to deal with the site random effects.

 

(We have the same challenge also for predictions of detection probability, where we have random effects of 597 observers, along with other predictors such as "first-time observer" or "date of year".)

 

As an aside, we can only report good things about fitting Nmix models with random effects. Things seem to work well and produce what look like reasonable estimates.

 

Thanks for any help,

 

best regards --- M, A & N

Ken Kellner

unread,
May 15, 2024, 8:13:38 AMMay 15
to unmarked
Hi Marc,

It depends what your goal is. If you want predictions that reflect specific levels of the random effect, include those in the newdata. If you want just a 'grand mean' estimate for a particular year that ignores any particular level of the random effect, set the option re.form=NA in the predict options (following lme4).  This will calculate predictions based only on the fixed effects. If you want to predict for new levels of the random effect not found in the data, you'll unfortunately have to do that manually.

Ken

Marc Kery

unread,
May 15, 2024, 9:38:19 AMMay 15
to unmarked
Dear Ken,

thanks for the quick and helpful reply. If we want to ignore the random effects, do we still have to add the random effects factor in the prediction data frame ?

Thanks and best regards  --- Marc


From: unma...@googlegroups.com <unma...@googlegroups.com> on behalf of Ken Kellner <con...@kenkellner.com>
Sent: Wednesday, May 15, 2024 14:13
To: unmarked <unma...@googlegroups.com>
Subject: [unmarked] Re: prediction with random effects in Nmix model
 
--
*** 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/daccbde3-dce2-4f4d-b6a2-341e0796f62dn%40googlegroups.com.

Ken Kellner

unread,
May 15, 2024, 9:40:23 AMMay 15
to unmarked
You should be able to leave it out of the prediction data frame if you set re.form=NA.

Ken

Marc Kery

unread,
May 15, 2024, 10:21:20 AMMay 15
to unmarked

Thanks, Ken, will try.

 

Marc

Reply all
Reply to author
Forward
0 new messages