首页 > 解决方案 > 尝试拟合混合混合模型时 secr.fit 的错误“FUN 中的错误(X[[i]],...):”

问题描述

在考虑了小插曲和在论坛上搜索后,我无法解决以下错误。

我正在使用 R 中的包 secr(由 Murray Efford 开发)进行多会话分析。

当我运行这个模型时

 fit_age0 <- secr.fit(bothCH, mask = mask,  detectfn = 2, trace = F, hcov = 'age') 

我收到这个错误

FUN(X[[i]], ...) 中的错误:当第一天没有使用第一个检测器时,混合模型失败。

用于创建相关 capthist 文件的代码如下。如果我知道具体问题出在哪里,我会进一步减少这一点。请让我知道是否需要其他信息来帮助回答此问题。

library(secr)
library(RColorBrewer)
library(sp)
library(rgdal)
library(GISTools)
library(raster)
library(readxl)
#--------------------

###Input files and create capthist####
captfile <- "captfile_both.xlsx"
trapfile <- "trapfile_both.csv"

suggest.buffer(bothCH)
#########
#276 395#
#########

# quick and biased estimate of sigma (metres)
initialsigma_both <- RPSV(bothCH, CC = TRUE) 
initialsigma_both 
##############
#$`OUT`      #
#[1] 85.34081#
#            #
#$IN         #
#[1] 118.8134#
##############

buffer <- 800
bothCH <- read.capthist(captfile = captfile, trapfile = trapfile,
                        skip = 1, detector = "proximity",
                        covnames = c("age"))            

bothCH <- split(bothCH, grepl('IN',rownames(traps(bothCH))), bytrap = TRUE)

# drop last 2 occasions for OUT (no cameras working)
bothCH[[1]] <- subset(bothCH[[1]], occasions=1:78)
usage(traps(bothCH[[1]])) <- usage(traps(bothCH[[1]]))[,1:78]

#### Clear repeat observations
bothCH <- reduce(bothCH, dropunused = FALSE)    
verify(bothCH)

session(bothCH) <- c('OUT',"IN")

下面是我的陷阱文件和 capt 文件布局的示例。

陷阱文件格式

捕获文件格式

提前感谢您的任何建议,因为我真的很难完成这项分析。

完整的 capt 文件(虚拟数据)

完整的陷阱文件(实际数据)

标签: rspatialmixture-model

解决方案


推荐阅读