bin <- binning(earthquakes[, c("lon", "lat")], earthquakes$mag, nbin = c(30,30))
hden <- h.cv(as.bin.den(bin))
den <- np.den(bin, h = hden$h)
## Equivalent to:
## den <- np.den(earthquakes[, c("lon", "lat")], h = hden$h, nbin = c(30,30))
plot(den, main = 'Estimated log(density)')
Run the code above in your browser using DataLab