error using ranef function

168 views
Skip to first unread message

Cíntia da Costa

unread,
Dec 23, 2021, 11:31:12 AM12/23/21
to unmarked
Hello everyone,
I'm trying to set the  function for finite-sample number and proportion of occupied sites
  
fs.fn <- function(fm) { 
 Nocc <- sum(ranef(fm)@post[,2,]) 
 psi.fs <- Nocc / nrow(fm@data@y) 
 out <- c(Nocc = Nocc, psi.fs = psi.fs) return(out) }  

when I get to the stage:
fs.hat <- fs.fn(mod29)
PS: mod29 = occu(formula = ~temp + humi ~ land_5000m.enn, data = ufo)

The following error appears: 
"Error in UseMethod("ranef") :
  method not applicable for 'ranef' applied to a class object "c('unmarkedFitOccu', 'unmarkedFit')"

Any suggestions for dealing with this issue?




Ken Kellner

unread,
Dec 23, 2021, 11:43:41 AM12/23/21
to unmarked
My guess would be that you have loaded another package with a ranef function after unmarked, such as lme4, and it is masking the unmarked version of the function. Have you tried running this code in a new R session without any other packages loaded?

Ken

Marc Kery

unread,
Dec 23, 2021, 11:54:55 AM12/23/21
to unmarked
Could also do this: unmarked::ranef(....), right ?



From: unma...@googlegroups.com <unma...@googlegroups.com> on behalf of Ken Kellner <con...@kenkellner.com>
Sent: Thursday, December 23, 2021 17:43
To: unmarked <unma...@googlegroups.com>
Subject: [unmarked] Re: error using ranef function
 
--
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/5bd1fe76-2134-4eaa-a36a-f291589da395n%40googlegroups.com.

Ken Kellner

unread,
Dec 23, 2021, 12:14:22 PM12/23/21
to unmarked
Yes, that's probably a better and safer option! Thanks Marc.
Reply all
Reply to author
Forward
0 new messages