Error message in R when trying to run SECR model

105 views
Skip to first unread message

Lachlan McRae

unread,
Feb 27, 2021, 9:31:37 PM2/27/21
to secr
Hi everyone,

I'm currently following the "A tutorial on fitting spatially explicit capture–recapture models in secr " document but I keep getting an error message when trying to estimate sigma.

This is where I get up to:
library(secr)
setwd("C:/Users/lmcra/OneDrive/Desktop/Career/Uni/Honours/Data/Combined")
PossumCH <- read.capthist("CHistory.txt", "TrapLocations.txt", detector = "multi")
summary(PossumCH)
par(mar = c(1,1,3,1)) 
plot (PossumCH, tracks = TRUE)
m <- unlist(moves(PossumCH))
par(mar = c(3.2,4,1,1), mgp = c(2.1,0.6,0))
hist(m, breaks = seq(-61/2, 500,61), xlab = "Movement m", main = "")
initialsigma <- RPSV(PossumCH, CC = TRUE)
cat("Quick and biased estimate of sigma =", initialsigma, "m\n")

Once I click enter on the "cat..." line I get an error message saying Quick and biased estimate of sigma = Error in cat("Quick and biased estimate of sigma =", initialsigma, "m\n") : argument 2 (type 'list') cannot be handled by 'cat'

Does anyone know how to get passed this error?

Cheers,
Lachlan McRae

Russell J Gray

unread,
Feb 27, 2021, 9:36:09 PM2/27/21
to secr, Lachlan McRae
I could be wrong, but I suspect the error may be due to the "\" in "m\n" rather than using "/" for "m/n". 

--
Russell J. Gray
Wildlife Ecology & Conservation Consultant

0934581341 |  rjgray...@gmail.com
705 alligator ranch rd. New Smyrna Beach, FL, USA. 32168




--
You received this message because you are subscribed to the Google Groups "secr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/secrgroup/6459055f-737f-4f02-aa92-00d451aa2d63n%40googlegroups.com.

Lachlan McRae

unread,
Feb 27, 2021, 9:58:30 PM2/27/21
to Russell J Gray, secr
Cheers for the suggestion Russel but unfortunately that didn't work. Any other suggestions?

Regards,
Lachie

Russell J Gray

unread,
Feb 27, 2021, 10:23:48 PM2/27/21
to Lachlan McRae, secr
Sorry, I didn't realize it was an argument value of the cat() function. 

So I ran a reprex and it worked for me without error:

library(secr)
dbar(captdata)
initialsigma <- RPSV(captdata, CC = TRUE)
cat("Quick and biased estimate of sigma =", initialsigma, "m\n")

So I suspect something is wrong with the initialsigma value on your end. It should be a single value after you ran the RPSV() function. However, the error suggests that the value you inputted is a list rather than a value. So make sure you're running an unlisted version of your capthist in the RPSV function. 

--
Russell J. Gray
Wildlife Ecology & Conservation Consultant

0934581341 |  rjgray...@gmail.com
705 alligator ranch rd. New Smyrna Beach, FL, USA. 32168


Murray Efford

unread,
Feb 27, 2021, 11:49:44 PM2/27/21
to secr
That was my guess, too. If PossumCH is multi-session then it should work with initialsigma <- RPSV(PossumCH, CC = TRUE)[[1]].

Lachlan McRae

unread,
Feb 27, 2021, 11:53:22 PM2/27/21
to secr
That worked Murray! Cheers. I just needed to add "[[1]]" to the end.
Reply all
Reply to author
Forward
0 new messages