When is setting res argument necessary (Error in sqrt(diag(KDE[[i]]$H))/res :)?

118 views
Skip to first unread message

Jared Stabach

unread,
Aug 16, 2020, 11:12:32 AM8/16/20
to ctmm R user group
Hi Chris

I am calculating CTMM home ranges for an Arabian bustard dataset.  Nine individuals were tracked with PTT-100 tracking devices over a 3 to 4-year period with a 2-hour fix interval.  I am wondering when I should or perhaps should not be setting the 'res' argument in the akde function.  I ask because I am currently setting the resolution (to 250 m) of the AKDE output.  I did this for two reasons:

1) I thought I wanted an "apples to apples" comparison (same resolution for each individual), but this may not be valid because then the optimized UD output would be ignored for each individual.  Perhaps I only want to do this if I am looking at overlap between individual.  Setting/hard-coding the output resolution likely is not necessary in my scenario. 
2) I want to relate the UD output with the 250m resolution of MODIS NDVI/MSAVI.  This, however, would result in a grid output that again may not be optimized, given the data.  Makes sense for my study objectives, but perhaps not for the data.

In any event, if I set the resolution, I receive the following error, which I assume is because the bandwidth parameter is too small to calculate (resulting in NAs):
Error in sqrt(diag(KDE[[i]]$H))/res : 
  non-numeric argument to binary operator

Removing the hard-coded 'res' resolves this error, but I still wonder when I should or should not be setting the resolution.

Appreciate your thoughts and happy to provide additional information.

Jared



Here's an example of the routine I am following:

# Set intervals
interval <- 2
UnitVal <- "hour"

# Set the sampling interval 
dt <- interval %#% UnitVal

# Generate the Variogram
vg.cilla <- variogram(cilla, dt=dt)

# Guess the starting value to interactively evaluate best model
GUESS <- variogram.fit(vg.cilla, interactive= FALSE)

# Fit the best model to Variogram
cilla.mods <- ctmm.select(cilla, CTMM = GUESS, verbose = TRUE)

 # Calcualte the AKDE home range
cilla.akde <- akde(cilla,cilla.mods[[1]], weights = TRUE, res = 250)
Error in sqrt(diag(KDE[[i]]$H))/res : 
  non-numeric argument to binary operator

Christen Fleming

unread,
Aug 16, 2020, 4:00:38 PM8/16/20
to ctmm R user group
Hi Jared,

The res argument in akde() is relative to the bandwidth, so res=250 isn't going to be 250 meters, but 250 pixels per unit bandwidth. That said, I don't know why that error would happen with res=250. If you can send me a minimal working example to reproduce that error, then I'd like to take a look at it and fix it.

The optional arguments in akde() to make detailed choices of for the grid resolution and alignment go in the grid list argument (see help("akde")). If you want all of your UDs to have the same resolution and aligned pixels, then you just calculate everything in the same projection and either calculate them all simultaneously (which will give them the same grid, but could waste a lot of memory if they don't overlap) or give them the same grid$dr and set grid$align.to.origin=TRUE. The function overlap() is coded to require the exact same grid, so if you are running into a case where things are too spread out, but you want to calculate all pairwise overlaps, then I could update the code to make that possible with aligned grids rather than identical grids.

Best,
Chris
Reply all
Reply to author
Forward
0 new messages