Bootstrapping: error in statistics (data, original, ...): unused argument (original)

I have a database with position estimates and you want to calculate the monthly distribution of kernel usage. I can do this using the adehabitat package in R, but I would like to estimate the 95% confidence intervals for these values ​​using loading these samples from the database. Today I experimented with a boot package, but I'm still pretty new to R, and I need one more expert help! The main error message I get is the following:

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

Here's a look at the file I used:

  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 

Columns 5 and 6 are respectively X and Y positions. I will multiply this dataset for different months (ie Get files with the name "okt", "new", etc.). I tried to configure the kernelUD function in the adehabitat package as a function that I can call to boot, but so far no luck.

 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) 

Any help would be greatly appreciated!

M

+6
source share
1 answer

Well, the problem you are facing is that you are not using the boot function as the documentation you are accessing. From ?boot can see that the second argument is statistic :

A function that, when applied to data, returns a vector containing statistical data. When sim = "parametric", the first argument to statistics should be data. For each replicated simulation dataset, the returned ran.gen will be transmitted. In all other cases, statistics should take at least two arguments. The first argument passed will always be raw data. The second will be a vector of indices, frequencies or weights that define the bootstrap pattern.

Note that this means that your function must be defined to accept at least two arguments. Yours accepts only one (and then ignores it completely, oddly enough).

The idea is that you pass in the raw data and the pointer vector. Then you calculate your percentage statistics by a subset of the source data using these guidelines, which will make up the “bootstrapping sample”.

So instead:

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

You probably want to do something more:

 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) 

But I can’t diagnose any other errors you might get, as your example is not fully reproducible.

+5
source

Source: https://habr.com/ru/post/913961/


All Articles