我已经为R中的一个物种计算了一个核密度估计(KDE),为了简单起见,我在这里使用了来自spatstat的蚂蚁数据集(蚂蚁巢),并且我希望有一个图例标度,每个测量单位的蚂蚁巢数(例如米)。如果我正确理解KDE图例显示0到1之间的概率密度,我如何在“真实世界”密度中转换这个概率,例如每平方米的点数(蚂蚁巢)?
这里的例子是:
require("spatstat")
data(ants)
dat <- ants
# estimate bandwith
h_cox <- bw.diggle(dat)
# calculate KDE
kd_cox <- density(dat, h_cox, diggle=TRUE, se=TRUE, eps=diff(dat$window$xrange)/500)
# Plot KDE, contours and points
plot(kd_cox$estimate, main="KDE ants bw.diggle")
contour(kd_cox$estimate, labels="", add=TRUE, col=gray(.5))
points(dat)发布于 2020-05-11 14:44:50
感谢您给出了一个明确的问题,并给出了示例数据。
library(spatstat)原始ants数据以0.5英尺为单位提供:
ants
#> Marked planar point pattern: 97 points
#> Multitype, with levels = Cataglyphis, Messor
#> window: polygonal boundary
#> enclosing rectangle: [-25, 803] x [-49, 717] units (one unit = 0.5 feet)因此,原帖中的代码给出了每“0.5平方英尺”点数的强度,即每“四分之一平方英尺”的点数。使用没有参数的rescale来获得通常的脚:
ants_ft <- rescale(ants)
ants_ft
#> Marked planar point pattern: 97 points
#> Multitype, with levels = Cataglyphis, Messor
#> window: polygonal boundary
#> enclosing rectangle: [-12.5, 401.5] x [-24.5, 349.5] feet使用具有换算系数和名称的rescale来获得米:
ants_m <- rescale(ants_ft, 3.2808399, "m")
ants_m
#> Marked planar point pattern: 97 points
#> Multitype, with levels = Cataglyphis, Messor
#> window: polygonal boundary
#> enclosing rectangle: [-3.81, 122.3772] x [-7.4676, 106.5276] m研究区域面积和每平方米平均点数数:
area(ants_m)
#> [1] 9962.028
intensity(ants_m)
#> Cataglyphis Messor
#> 0.002911054 0.006825920
intensity(unmark(ants_m))
#> [1] 0.009736973用dat <- ants_m重新运行原始代码将给出以每平方米点数计算的估计强度:
dat <- ants_m
# estimate bandwith
h_cox <- bw.diggle(dat)
#> Warning: Berman-Diggle Cross-Validation criterion was minimised at right-hand
#> end of interval [0, 7.11]; use argument 'hmax' to specify a wider interval for
#> bandwidth 'sigma'
# calculate KDE
kd_cox <- density(dat, h_cox, diggle=TRUE, se=TRUE, eps=diff(dat$window$xrange)/500)
# Plot KDE, contours and points
plot(kd_cox$estimate, main="KDE ants bw.diggle")
contour(kd_cox$estimate, labels="", add=TRUE, col=gray(.5))
points(dat)

https://stackoverflow.com/questions/61728352
复制相似问题