r - Bootstrapping : Error in statistic(data, 原始,...):未使用的参数(原始)

标签 r

我有一个位置估计数据库,并且想要计算每月的内核利用率分布。我可以使用 R 中的 adehabitat 包来完成此操作,但我想使用引导数据库中的样本来估计这些值的 95% 置信区间。 今天我一直在尝试引导包,但我对 R 还很陌生,并且需要一些更专业的帮助! 我收到的主要错误消息是:

Error in statistic(data, original, ...) : unused argument(s) (original)

这是我一直使用的文件:

    head(all)
Num          Hourbin  COA_Lat   COA_Lon  POINT_X POINT_Y   month year    id
1 07/10/2010 15:00 48.56225 -53.89144 729339.9 5383461 October 2010 29912
2 07/10/2010 16:00 48.56254 -53.89121 729355.7 5383495 October 2010 29912
4 07/10/2010 18:00 48.56225 -53.89144 729339.7 5383461 October 2010 29912
5 07/10/2010 19:00 48.56225 -53.89144 729339.9 5383461 October 2010 29912
6 07/10/2010 20:00 48.56225 -53.89144 729339.8 5383461 October 2010 29912
7 07/10/2010 21:00 48.56225 -53.89144 729339.9 5383461 October 2010 29912

第 5 列和第 6 列分别是 X 和 Y 位置。我将这个数据集划分为不同月份(即获取名为“oct”、“nov”等的文件)。我尝试过将 adehabitat 包中的 kernelUD 函数设置为可以调用进行引导的函数,但到目前为止还没有成功。

kUDoct<-function(i) kernel.area(oct[,5:6],oct[,10],kern="bivnorm",unin=c("m"),unout=c("km2"))
bootoct<-boot(oct,kUDoct,R=1000)
Error in statistic(data, original, ...) : unused argument(s) (original)

任何帮助将不胜感激!

中号

最佳答案

嗯,您遇到的问题是您没有按照文档的指示使用 boot 函数。从 ?boot 我们看到第二个参数 statistic 是:

A function which when applied to data returns a vector containing the statistic(s) of interest. When sim = "parametric", the first argument to statistic must be the data. For each replicate a simulated dataset returned by ran.gen will be passed. In all other cases statistic must take at least two arguments. The first argument passed will always be the original data. The second will be a vector of indices, frequencies or weights which define the bootstrap sample.

请注意,这意味着您的函数应定义为至少采用两个参数。你只接受一个(然后完全忽略它,很奇怪)。

这个想法是传递原始数据和索引向量。然后,您通过使用这些索引对原始数据进行子集化来计算您感兴趣的统计数据,这将构成“引导样本”。

所以代替这个:

kUDoct<-function(i) kernel.area(oct[,5:6],oct[,10],kern="bivnorm",unin=c("m"),unout=c("km2"))
bootoct<-boot(oct,kUDoct,R=1000)

您可能想做类似这样的事情:

kUDoct<-function(dat,ind) kernel.area(dat[ind,5:6],dat[ind,10],kern="bivnorm",unin=c("m"),unout=c("km2"))
bootoct<-boot(oct,kUDoct,R=1000)

但我无法诊断您可能遇到的任何其他错误,因为您的示例不能完全重现。

关于r - Bootstrapping : Error in statistic(data, 原始,...):未使用的参数(原始),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10285214/

相关文章:

r - 使用 frame 参数绘制从 ggplot 到 plotly 的图

r - 如何从另一个包中仅导入一个函数,而不加载整个命名空间

r - 减少 knitr block 中命令和输出之间的空间

r - R中的嵌套字典

r - 使用 `eval` 和 `local` 的函数范围

r - 在 R 中使用 IF 函数

javascript - R/Shiny 的 dygraphs 包中突出显示图例的系列

R ggplot2 : add significance level to line plot

r - 计算 2 个经纬度之间的距离

r - R 中的内存分析 - 总结工具