I have a database of position estimates, and want to calculate monthly kernel utilization distributions. I can do this using the adehabitat package in R, but I would like to estimate 95%confidence intervals for these values using bootstrapping that samples from the database. Today I've been experimenting with the boot package, but I am still fairly new to R and am needing some more expert help! The main error message I'm getting is:
Error in statistic(data, original, ...) : unused argument(s) (original)
Here is a look at the file I've been using:
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
With columns 5 and 6 being the X and Y positions respectively. I subset this dataset for different months (ie getting files named "oct","nov",etc). I have tried setting up the kernelUD function in the adehabitat package to be a function that I can call up for bootstrapping, but have had no luck so far.
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
Well, a problem that you're having is that you aren't using the boot
function as the documentation direct you to. From ?boot
we see that the second argument, statistic
is:
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.
Note that this means your function should be defined to take at least two arguments. Your accepts only one (and then ignores it completely, oddly enough).
The idea is that you pass in your original data, and a vector of indicies. Then you calculate your statistic of interest by subsetting your original data using those indicies, which will constitute a "bootstrap sample".
So instead of this:
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'd probably want to do something more like this:
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 may get, as your example isn't entirely reproducible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With