| lgcp_graph | R Documentation |
This function fits log-Gaussian Cox process (LGCP) models for point pattern data on metric graphs using R-INLA. It handles the complex setup required for LGCP modeling, including creation of integration points, data preparation, and interface with INLA's Poisson likelihood framework. The function supports both exact and rational SPDE approximations, multiple replicates, and efficient refitting using precomputed quantities.
lgcp_graph(
formula,
graph,
interpolate = TRUE,
manual_integration_points = NULL,
manual_covariates = NULL,
use_current_mesh = TRUE,
new_h = NULL,
new_n = NULL,
repl = ".all",
repl_col = ".group",
clone_graph = TRUE,
precomputed_data = NULL,
...
)
formula |
A formula object specifying the model structure. Should follow
INLA syntax, e.g., |
graph |
A |
interpolate |
Logical. If |
manual_integration_points |
Data frame with columns |
manual_covariates |
Data frame containing covariate values at integration
points when |
use_current_mesh |
Logical. If |
new_h |
Numeric. Mesh resolution for creating a new mesh when
|
new_n |
Integer. Alternative to |
repl |
Character vector or |
repl_col |
Character. Name of the column in the graph data that contains
replicate identifiers. Default is |
clone_graph |
Logical. If |
precomputed_data |
Optional object of class |
... |
Additional arguments passed to |
The function implements LGCP modeling using the approach of Simpson et al. (2016),
where the log-Gaussian Cox process with intensity \lambda(s) = exp(\eta(s)) is
approximated using a Poisson likelihood with carefully constructed integration
points and weights.
The key steps are:
Create integration points (typically mesh nodes) across the graph
Set up data with observed points (response = 1, weights = 0) and integration points (response = 0, weights = integration weights)
Fit using Poisson regression with the constructed weights as exposure
The spatial component can be modeled using:
Exact SPDE models via graph_spde() (slower setup, exact likelihood)
Rational SPDE approximations via rspde.metric_graph() (faster, approximate)
An object of class "inla" containing the fitted LGCP model. This
includes posterior marginal distributions for model parameters, fitted
values, and other standard INLA output components. Use
spde_metric_graph_result() to extract spatial parameter estimates in
their original scale.
For fitting multiple models with the same spatial structure:
Use precompute_lgcp_graph() first, then lgcp_graph() with
precomputed_data for substantial speedups
Set clone_graph = FALSE for additional performance gains when
you don't need to preserve the original graph
Simpson, D., Illian, J., Lindgren, F., Sørbye, S., & Rue, H. (2016). Going off grid: Computationally efficient inference for log-Gaussian Cox processes. Biometrika, 103(1), 49-70.
graph_lgcp_sim for simulating LGCP data,
precompute_lgcp_graph for efficient model refitting,
graph_spde for exact SPDE models,
spde_metric_graph_result for extracting spatial parameter estimates
## Not run:
# Setup: Create graph with mesh and add point pattern data
graph <- metric_graph$new()
graph$build_mesh(h = 0.1)
graph$add_observations(data = your_point_data,
edge_number = "edge_id",
distance_on_edge = "location")
# Create SPDE model
spde_model <- graph_spde(graph, alpha = 1)
# or: rspde_model <- rspde.metric_graph(graph, nu = 1.5)
# Fit basic LGCP model
fit1 <- lgcp_graph(y ~ 1 + f(field, model = spde_model),
graph = graph)
# Fit model with covariates
fit2 <- lgcp_graph(y ~ elevation + temperature +
f(field, model = spde_model),
graph = graph)
# Extract spatial parameter estimates
spde_result <- spde_metric_graph_result(fit2, "field", spde_model)
summary(spde_result)
# Efficient fitting of multiple models
precomputed <- precompute_lgcp_graph(
graph = graph,
resp_variable_name = "y",
model_name = "field",
spde_model = spde_model,
covariates = c("elevation", "temperature", "slope")
)
# Now fit multiple models efficiently
fit_a <- lgcp_graph(y ~ elevation + f(field, model = spde_model),
graph = graph, precomputed_data = precomputed)
fit_b <- lgcp_graph(y ~ elevation + temperature + f(field, model = spde_model),
graph = graph, precomputed_data = precomputed)
fit_c <- lgcp_graph(y ~ slope + f(field, model = spde_model),
graph = graph, precomputed_data = precomputed)
# Model with replicates
fit_rep <- lgcp_graph(y ~ covariate + f(field, model = spde_model,
replicate = field.repl),
graph = graph)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.