Bootstrapping:统计错误(数据,原始,...):未使用的参数(原)

问题描述:

我有一个位置估计数据库,并且想要计算每月的内核利用率分布。我可以使用R中的adehabitat软件包来做到这一点,但我想使用从数据库中抽取样本来估计这些值的95%置信区间。 今天我一直在试用启动包,但我对R还是比较新的,需要更多的专家帮助! 我得到的主要错误消息是:Bootstrapping:统计错误(数据,原始,...):未使用的参数(原)

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函数作为我可以调用bootstrapping的函数,但迄今为止还没有运气。

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) 

任何帮助将不胜感激!

中号

+1

什么是'kernel.area'? “全部”在哪里? “oct”看起来像什么?为什么'kUDoct'没有在体内使用索引'i'? – 2012-04-23 17:41:28

好,说你有一个问题是,你不使用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) 

但我不能诊断任何其他错误,你可能会得到,因为你示例不完全可重现。

+0

感谢您的快速响应!我意识到我只有一个论点,所以我做了类似于你现在正在运行的建议,所以我们会看看它是否有效! kudoct user1195564 2012-04-23 17:52:41

+0

@ user1195564这是行不通的。仔细看看我的例子,以及''boot'中的例子。 – joran 2012-04-23 17:53:49

+0

啊,是的,我明白我要去哪里错了。我会按照您的建议来设置格式,并尝试一下。谢谢! – user1195564 2012-04-23 17:56:31