error with modavg() and colext models

41 views
Skip to first unread message

Scott Pearson

unread,
Oct 10, 2025, 11:45:48 AM (6 days ago) Oct 10
to unmarked
I am seeing a new error with R ver. 4.5.1 when using modavg() to compute model averaged parameter estimates from a set of colext() models.  Here is example code from the modavg help page that now throws the error: 
---------
library(AICcmodavg) # ver. 2.3-4
require(unmarked) # ver. 1.5.1

data(frogs)
umf <- formatMult(masspcru)
obsCovs(umf) <- scale(obsCovs(umf))
siteCovs(umf) <- rnorm(numSites(umf))
yearlySiteCovs(umf) <- data.frame(year = factor(rep(1:7,
                                    numSites(umf))))

fm <- colext(psiformula = ~ 1, gammaformula = ~ 1, epsilonformula = ~ 1,
             pformula = ~ JulianDate + I(JulianDate^2), data = umf,
             control = list(trace=1, maxit=1e4))

fm.yearly <- colext(psiformula = ~ 1, gammaformula = ~ year,
                    epsilonformula = ~ year,
                    pformula = ~ JulianDate + I(JulianDate^2),
                    data = umf)

Cand.mods <- list(fm, fm.yearly)
Modnames <- c("psi1(.)gam(.)eps(.)p(Date + Date2)",
              "psi1(.)gam(Year)eps(Year)p(Date + Date2)")

modavg(cand.set = Cand.mods, modnames = Modnames, parm = "(Intercept)",
       parm.type = "psi")
# Error in FUN(X[[i]], ...) :
#   no slot of name "psiformula" for this object of class "unmarkedFitColExt"


modavg(cand.set = Cand.mods, modnames = Modnames,
       parm = "I(JulianDate^2)", parm.type = "detect")
# Error in FUN(X[[i]], ...) :
#   no slot of name "detformula" for this object of class "unmarkedFitColExt"
---------
Thanks for any advice,
Scott P.

Ken Kellner

unread,
Oct 10, 2025, 11:53:35 AM (6 days ago) Oct 10
to 'Scott Pearson' via unmarked
Hi Scott,

This is due to an internal change in unmarked in version 1.5.1 that results in an incompability with AICcmodavg. One short-term solution is to revert to the previous version of unmarked (1.5.0). Alternatively, I've attached a patch file. If you load unmarked and AICcmodavg, then run

source("patch.R")

The modavg function should work again. I'll work on a permanent fix.

Ken

On Fri, Oct 10, 2025 at 07:42:52AM -0700, 'Scott Pearson' via unmarked wrote:
> I am seeing a new error with R ver. 4.5.1 when using *modavg()* to compute
> model averaged parameter estimates from a set of *colext()* models. Here
> is example code from the *modavg* help page that now throws the error:
> ---------
> library(AICcmodavg) # ver. 2.3-4
> require(unmarked) # ver. 1.5.1
>
> data(frogs)
> umf <- formatMult(masspcru)
> obsCovs(umf) <- scale(obsCovs(umf))
> siteCovs(umf) <- rnorm(numSites(umf))
> yearlySiteCovs(umf) <- data.frame(year = factor(rep(1:7,
> numSites(umf))))
>
> fm <- colext(psiformula = ~ 1, gammaformula = ~ 1, epsilonformula = ~ 1,
> pformula = ~ JulianDate + I(JulianDate^2), data = umf,
> control = list(trace=1, maxit=1e4))
>
> fm.yearly <- colext(psiformula = ~ 1, gammaformula = ~ year,
> epsilonformula = ~ year,
> pformula = ~ JulianDate + I(JulianDate^2),
> data = umf)
>
> Cand.mods <- list(fm, fm.yearly)
> Modnames <- c("psi1(.)gam(.)eps(.)p(Date + Date2)",
> "psi1(.)gam(Year)eps(Year)p(Date + Date2)")
>
> modavg(cand.set = Cand.mods, modnames = Modnames, parm = "(Intercept)",
> parm.type = "psi")
>
> *# Error in FUN(X[[i]], ...) : # no slot of name "psiformula" for this
> object of class "unmarkedFitColExt"*
>
> modavg(cand.set = Cand.mods, modnames = Modnames,
> parm = "I(JulianDate^2)", parm.type = "detect")
>
> *# Error in FUN(X[[i]], ...) : # no slot of name "detformula" for this
> object of class "unmarkedFitColExt"*
> ---------
> Thanks for any advice,
> Scott P.
>
> --
> *** 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 visit https://groups.google.com/d/msgid/unmarked/16a7c0bd-ebfb-452f-aff3-d8d846e443e2n%40googlegroups.com.

Ken Kellner

unread,
Oct 10, 2025, 11:56:04 AM (6 days ago) Oct 10
to 'Scott Pearson' via unmarked
Forgot to attach the file.

On Fri, Oct 10, 2025 at 07:42:52AM -0700, 'Scott Pearson' via unmarked wrote:
> I am seeing a new error with R ver. 4.5.1 when using *modavg()* to compute
> model averaged parameter estimates from a set of *colext()* models. Here
> is example code from the *modavg* help page that now throws the error:
> ---------
> library(AICcmodavg) # ver. 2.3-4
> require(unmarked) # ver. 1.5.1
>
> data(frogs)
> umf <- formatMult(masspcru)
> obsCovs(umf) <- scale(obsCovs(umf))
> siteCovs(umf) <- rnorm(numSites(umf))
> yearlySiteCovs(umf) <- data.frame(year = factor(rep(1:7,
> numSites(umf))))
>
> fm <- colext(psiformula = ~ 1, gammaformula = ~ 1, epsilonformula = ~ 1,
> pformula = ~ JulianDate + I(JulianDate^2), data = umf,
> control = list(trace=1, maxit=1e4))
>
> fm.yearly <- colext(psiformula = ~ 1, gammaformula = ~ year,
> epsilonformula = ~ year,
> pformula = ~ JulianDate + I(JulianDate^2),
> data = umf)
>
> Cand.mods <- list(fm, fm.yearly)
> Modnames <- c("psi1(.)gam(.)eps(.)p(Date + Date2)",
> "psi1(.)gam(Year)eps(Year)p(Date + Date2)")
>
> modavg(cand.set = Cand.mods, modnames = Modnames, parm = "(Intercept)",
> parm.type = "psi")
>
> *# Error in FUN(X[[i]], ...) : # no slot of name "psiformula" for this
> object of class "unmarkedFitColExt"*
>
> modavg(cand.set = Cand.mods, modnames = Modnames,
> parm = "I(JulianDate^2)", parm.type = "detect")
>
> *# Error in FUN(X[[i]], ...) : # no slot of name "detformula" for this
> object of class "unmarkedFitColExt"*
> ---------
> Thanks for any advice,
> Scott P.
>
patch.R

Scott Pearson

unread,
Oct 10, 2025, 12:01:24 PM (6 days ago) Oct 10
to unmarked
Thank you, Ken.  The patch worked.  --Scott

Marc J. Mazerolle

unread,
Oct 10, 2025, 12:02:50 PM (6 days ago) Oct 10
to unma...@googlegroups.com
Hi Scott,

Thanks for pointing this out. I'll make the changes in AICcmodavg. 

Best,

Marc
--
____________________________________
Marc J. Mazerolle
Professeur titulaire et directeur du bac. en environnements naturels et
aménagés
Département des sciences du bois et de la forêt
2405 rue de la Terrasse
Université Laval
Québec, Québec G1V 0A6, Canada
Tel: (418) 656-2131 ext. 407120
Email: marc.ma...@sbf.ulaval.ca


-------- Message initial --------
De: 'Scott Pearson' via unmarked <unma...@googlegroups.com>
Répondre à: unma...@googlegroups.com
À: unmarked <unma...@googlegroups.com>
Objet: [unmarked] error with modavg() and colext models
Date: 2025-10-10 10:42:52
Reply all
Reply to author
Forward
0 new messages