2012-04-23 79 views
6

我有一個位置估計數據庫,並且想要計算每月的內核利用率分佈。我可以使用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

回答

5

好,說你有一個問題是,你不使用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 <-function(data,indices)kUDoct <-kernel.area(oct [,5:6],oct [,10],kern =「bivnorm」,unin = c(「m」),unout = c (「km2」)) return(summary(kUDoct)) } bootoct <-boot(data = oct,statistic = kudoct,R = 1000) – 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