"Error in kernelUD: At least 5 relocations required to fit a home range" 但每组有超过 5 个搬迁

"Error in kernelUD: At least 5 relocations required to fit a home range" but have many more than 5 relocations per group

我一直在根据不同时间尺度的人口和每群犬科动物对一个地区的犬科动物群体进行核密度家庭范围估计。但是,当我尝试对每年的一个子集进行 运行 kernelUD 时,我得到 Error in kernelUD(P17.sp[, "Pack"], h = "href", grid = 500, same4all = TRUE) : At least 5 relocations are required to fit an home range。我之前消除了所有搬迁次数少于 5 次的组,当我仔细检查我的数据框时,最少的搬迁次数是 201。我能够 运行 在全球数据集上(跨年)每包并且没有问题。任何帮助或见解将不胜感激。

我使用的代码如下。我的原始数据框将 Pack 作为一个因子(并且是数据框中唯一的因子向量)和 lat/long.

中的数字坐标
library(dplyr)
library(raster)
library(sp)
library(adehabitatHR)
library(lubridate)
library(data.table)

# Make spatial
Final.sp <- copy(Final)
coordinates(Final.sp) <- c("Longitude", "Latitude")
proj4string(Final.sp) <- CRS( "+init=epsg:4326")

#Subset by year
P17.sp <- Final.sp[Final.sp@data$Year == 2017, ]

# Make sure every pack has at least 5 relocations
P17 <- as.data.frame(P17.sp)
P17 %>% group_by(Pack) %>% summarise(n()) %>% view()

# What the output from above looks like
    Year       Pack         n()
#1  2017    Gryffindor      201
#2  2017    Slytherin       222
#3  2017    Hufflepuff      234
#4  2017    Ravenclaw       281
#5  2017    Deatheaters     306
#6  2017    Muggles         577
#7  2017    Dementors       582
#8  2017    Hobbits         787
#9  2017    Elves           861
#10 2017    Orcs            914

# Create KDEs
P17.kde <- kernelUD(P17.sp[,"Pack"], h="href", grid=500, same4all = TRUE)

Error in kernelUD(WP17.sp[, "Pack"], h = "href", grid = 200, same4all = TRUE) : 
  At least 5 relocations are required to fit an home range```

成功了。它似乎携带了子年没有数据的包,并且它们没有出现在我的 dplyr table 中,目的是检查数据是否正确。 ftable 能够向我显示每个包的级别和相关点数。以下代码现在有效:

# Subset by year
P17.sp <- Final.sp[Final.sp@data$Year == 2017, ]

# Refactor pack or else it will include packs from other years with no data for subset year
P17.sp@data$Pack <- factor(P17.sp@data$Pack)

# Double check all packs have at least 5 relocations
as.data.frame(ftable(P17.sp@data$Pack))

# Create KDEs
P17.kde <- kernelUD(P17.sp[,"Pack"], h="href", grid=500, same4all = TRUE)

希望这对遇到此问题的其他人有所帮助。