<h1 align="center"> R Code file description for fitting LGCP based on the VoGCAM algorithm</h1>

Set the current working directory to the location of the `supplement` folder. Below, we first provide an overview of all R code files included in the directory, followed by a description of the experimental workflow.

# R Code File Description
## Simulation
- `./src/data_pattern_generator.R`: Simulates point patterns generated by an LGCP model, covering both the "full case" and "hole case" scenarios.
- `lgcp_full_case.R` and `lgcp_hole_case.R`: Generate observation points, covariates, and the integration points and weights required for approximating the LGCP likelihood under the "full case" and "hole case" settings, respectively.

## Model fitting
- `./src/dual_mesh_loc.R`: Performs Voronoi tessellation over the observation domain to obtain integration points and weights used in approximating the LGCP likelihood.
- `./src/NNMatrix.R` and `./src/functions.R`: Contain functions for efficiently computing the NNGP approximation of the prior covariance matrix. These files are adapted from https://github.com/LuZhangstat/ConjugateNNGP 。
- `nngp_prior.R` and `nngp_prior_hole.R`: Compute the NNGP prior approximation for the "full case" and "hole case" scenarios, respectively.
- `optimization_hyper.R`: The core implementation of the VoGCAM algorithm.
- `full_case_result.R` and `hole_case_result.R`: Provide comparison results between the proposed method and INLA and VIFRK under the "full case" and "hole case" scenarios, respectively.

## Experimental Results
- `VoGCAM_convergence.R`: Verifies the convergence of the VoGCAM algorithm.
- `./src/logintensity_vis.R`: Visualizes the posterior mean surface and posterior standard error surface of the LGCP log-intensity.
- `plot_result.R`: Plots and compares the LGCP log-intensity posterior mean surface and posterior standard error surface obtained by VoGCAM, INLA, and VIFRK under both "full case" and "hole case" scenarios.

# Experimental Workflow
To reproduce the results for the "full case" and "hole case" scenarios, run the following scripts in order:
- "full case": `lgcp_full_case.R` -> `nngp_prior.R` -> `full_case_result.R`.
- "hole case": `lgcp_hole_case.R` -> `nngp_prior_hole.R` -> `hole_case_result.R`.
Finally, run `VoGCAM_convergence.R` and `plot_result.R` to generate Figures 3 and 4 as presented in the paper.