if (FALSE) {
if (require(ggplot2) && require(fmesher)) {
# Load a point pattern
data(Poisson2_1D)
# Take a look at the point (and frequency) data
ggplot(pts2) +
geom_histogram(
aes(x = x),
binwidth = 55 / 20,
boundary = 0,
fill = NA,
color = "black"
) +
geom_point(aes(x), y = 0, pch = "|", cex = 4) +
coord_fixed(ratio = 1)
# Fit an LGCP model
x <- seq(0, 55, length.out = 50)
mesh1D <- fm_mesh_1d(x, boundary = "free")
mdl <- x ~ spde1D(x, model = inla.spde2.matern(mesh1D)) + Intercept(1)
fit.spde <- lgcp(mdl, pts2, domain = list(x = c(0, 55)))
# Calculate bin statistics
bc <- bincount(
result = fit.spde,
observations = pts2,
breaks = seq(0, max(pts2), length.out = 12),
predictor = x ~ exp(spde1D + Intercept)
)
# Plot them!
attributes(bc)$ggp
}
}
Run the code above in your browser using DataLab