R Under development (unstable) (2026-03-01 r89508) -- "Unsuffered Consequences" Copyright (C) 2026 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > pkgname <- "ldmppr" > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > library('ldmppr') > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') > cleanEx() > nameEx("check_model_fit") > ### * check_model_fit > > flush(stderr()); flush(stdout()) > > ### Name: check_model_fit > ### Title: Check the fit of an estimated model using global envelope tests > ### Aliases: check_model_fit > > ### ** Examples > > # Note: The example below is provided for illustrative purposes and may take some time to run. > > > > cleanEx() > nameEx("estimate_process_parameters") > ### * estimate_process_parameters > > flush(stderr()); flush(stdout()) > > ### Name: estimate_process_parameters > ### Title: Estimate point process parameters using log-likelihood > ### maximization > ### Aliases: estimate_process_parameters > > ### ** Examples > > # Load example data > data(small_example_data) > > # Define grids and budgets > ub <- c(1, 25, 25) > g <- ldmppr_grids(upper_bounds = ub, levels = list(c(10,10,10))) > b <- ldmppr_budgets( + global_options = list(maxeval = 150), + local_budget_first_level = list(maxeval = 50, xtol_rel = 1e-2), + local_budget_refinement_levels = list(maxeval = 25, xtol_rel = 1e-2) + ) > > # Estimate parameters using a single delta value > fit <- estimate_process_parameters( + data = small_example_data, + grids = g, + budgets = b, + delta = 1, + strategy = "global_local", + global_algorithm = "NLOPT_GN_CRS2_LM", + local_algorithm = "NLOPT_LN_BOBYQA", + starts = list(global = 2, local = 2, jitter_sd = 0.25, seed = 1), + verbose = TRUE + ) [ldmppr::estimate_process_parameters] Using default starting values (parameter_inits) since none were provided. Initial values: 3.125, 4.805, 0.03963, 2.369, 2, 0.5, 2.369, 0.1 Estimating self-correcting process parameters Strategy: global_local Delta: 1 Grids: 1 level(s) Local optimizer: NLOPT_LN_BOBYQA Global optimizer: NLOPT_GN_CRS2_LM Rescore control: enabled=TRUE, top=5, objective_tol=1e-06, param_tol=0.1 Starts: global=2, local=2, jitter_sd=0.25, seed=1 Parallel: off Step 1/2: Preparing data and objective function... Prepared 121 points. Done in 0.0s. Step 2/2: Optimizing parameters... Single level (grid 10x10x10) Global search: 2 restart(s), then local refinement. Local multi-start: 2 start(s). Completed in 3.7s. Best objective: 188.04405 Finished. Total time: 3.7s. > coef(fit) [1] 2.290657e+00 4.130412e+00 5.970705e-05 2.795717e+00 2.053278e+00 [6] 4.086056e-01 2.695652e+00 1.139847e-01 > logLik(fit) 'log Lik.' -188.0441 (df=8) > > > > > > cleanEx() > nameEx("extract_covars") > ### * extract_covars > > flush(stderr()); flush(stdout()) > > ### Name: extract_covars > ### Title: Extract covariate values from a set of rasters > ### Aliases: extract_covars > > ### ** Examples > > # Load example raster data > raster_paths <- list.files(system.file("extdata", package = "ldmppr"), + pattern = "\\.tif$", full.names = TRUE + ) > raster_paths <- raster_paths[!grepl("_med\\.tif$", raster_paths)] > rasters <- lapply(raster_paths, terra::rast) > > # Scale the rasters > scaled_raster_list <- scale_rasters(rasters) > > # Load example locations > locations <- small_example_data %>% + dplyr::select(x, y) %>% + as.matrix() > > # Extract covariates > example_covars <- extract_covars(locations, scaled_raster_list) > head(example_covars) Snodgrass_DEM_1m Snodgrass_aspect_southness_1m Snodgrass_slope_1m 1 -0.3878719 -0.2481063 0.4541215 2 -1.3977397 1.7131221 0.6044641 3 1.6946886 -1.1153459 -1.5861887 4 0.7115911 -0.9918452 -1.9867798 5 1.4753020 -0.5887282 -1.3989392 6 1.5844332 0.7520857 -2.1610400 Snodgrass_wetness_index_1m 1 -0.4099315 2 -0.2639008 3 1.2917963 4 2.0485587 5 0.9809867 6 1.8836371 > > > > > cleanEx() > nameEx("generate_mpp") > ### * generate_mpp > > flush(stderr()); flush(stdout()) > > ### Name: generate_mpp > ### Title: Generate a marked process given locations and marks > ### Aliases: generate_mpp > > ### ** Examples > > # Load example data > data(small_example_data) > > # Generate a marked point process > generate_mpp( + locations = small_example_data %>% dplyr::select(x, y), + marks = small_example_data$size, + xy_bounds = c(0, 25, 0, 25) + ) Marked planar point pattern: 121 points marks are numeric, of storage type ‘double’ window: rectangle = [0, 25] x [0, 25] units > > > > > cleanEx() > nameEx("ldmppr_budgets") > ### * ldmppr_budgets > > flush(stderr()); flush(stdout()) > > ### Name: ldmppr_budgets > ### Title: Create an optimization budget specification for > ### estimate_process_parameters() > ### Aliases: ldmppr_budgets > > ### ** Examples > > b <- ldmppr_budgets( + global_options = list(maxeval = 150), + local_budget_first_level = list(maxeval = 300, xtol_rel = 1e-5), + local_budget_refinement_levels = list(maxeval = 150, xtol_rel = 1e-5) + ) > b global_options: - maxeval: 150 - maxtime: NA local_budget_first_level: - maxeval: 300 - maxtime: NA - xtol_rel: 1e-05 local_budget_refinement_levels: - maxeval: 150 - maxtime: NA - xtol_rel: 1e-05 > > > > cleanEx() > nameEx("ldmppr_grids") > ### * ldmppr_grids > > flush(stderr()); flush(stdout()) > > ### Name: ldmppr_grids > ### Title: Create a grid schedule for estimate_process_parameters() > ### Aliases: ldmppr_grids > > ### ** Examples > > # A 3-level coarse-to-fine schedule (counts per dimension) > g <- ldmppr_grids( + upper_bounds = c(1, 50, 50), + levels = list( + c(25, 25, 25), + c(75, 75, 75), + c(100, 100, 100) + ) + ) > g upper_bounds: b_t=1, b_x=50, b_y=50 levels: 3 - level 1: 25x25x25 [x:0..50, y:0..50, t:0..1] - level 2: 75x75x75 [x:0..50, y:0..50, t:0..1] - level 3: 100x100x100 [x:0..50, y:0..50, t:0..1] > length(g) [1] 3 > summary(g) levels: 3 dims: nx ny nt [1,] 25 25 25 [2,] 75 75 75 [3,] 100 100 100 > > # Explicit vectors (single level) > g2 <- ldmppr_grids( + upper_bounds = c(1, 50, 50), + levels = list(list( + x = seq(0, 50, by = 2), + y = seq(0, 50, by = 2), + t = seq(0, 1, length.out = 30) + )) + ) > as.data.frame(g2) level label nx ny nt x_min x_max y_min y_max t_min t_max 1 1 26 26 30 0 50 0 50 0 1 > > > > cleanEx() > nameEx("plot_mpp") > ### * plot_mpp > > flush(stderr()); flush(stdout()) > > ### Name: plot_mpp > ### Title: Plot a marked point process > ### Aliases: plot_mpp > > ### ** Examples > > # Load example data > data(small_example_data) > mpp_data <- generate_mpp( + locations = small_example_data %>% dplyr::select(x, y), + marks = small_example_data$size, + xy_bounds = c(0, 25, 0, 25) + ) > > # Plot the marked point process > plot_mpp(mpp_data, pattern_type = "reference") > > > > > cleanEx() > nameEx("power_law_mapping") > ### * power_law_mapping > > flush(stderr()); flush(stdout()) > > ### Name: power_law_mapping > ### Title: Gentle decay (power-law) mapping function from sizes to arrival > ### times > ### Aliases: power_law_mapping > > ### ** Examples > > # Generate a vector of sizes > sizes <- runif(100, 0, 100) > > # Map the sizes to arrival times using a power-law mapping with delta = .5 > power_law_mapping(sizes, .5) [1] 0.49240387 0.39451680 0.24386075 0.04372388 0.56133644 0.04898457 [7] 0.02443238 0.18659856 0.20675193 0.77760729 0.55636433 0.59165102 [13] 0.17028755 0.38448985 0.12076187 0.29647859 0.15165445 0.00000000 [19] 0.38787674 0.11635390 0.02966849 0.54931610 0.19235060 0.66143325 [25] 0.49068338 0.38282315 1.00000000 0.38591587 0.06453145 0.42195385 [31] 0.30791597 0.22601968 0.29950507 0.57973597 0.08793928 0.18179512 [37] 0.10669500 0.68914746 0.14799274 0.36233236 0.09154713 0.19527478 [43] 0.11318634 0.25737330 0.27359395 0.10949286 0.89920749 0.31150616 [49] 0.14284888 0.16677926 0.31121710 0.06917573 0.34118924 0.51369999 [55] 0.75803607 0.70340987 0.44364452 0.28143404 0.18584050 0.36590364 [61] 0.04123275 0.46486882 0.32512178 0.42902856 0.19285899 0.50000255 [67] 0.31053076 0.12281620 0.73090466 0.06146097 0.42308296 0.08120365 [73] 0.41638118 0.42779467 0.31215870 0.05231700 0.06745910 0.37962286 [79] 0.11642591 0.01611741 0.34386090 0.15473419 0.37143633 0.43536628 [85] 0.12820565 0.56016114 0.15557698 0.66731479 0.51297421 0.63562872 [91] 0.51916076 0.78425940 0.19831055 0.06094505 0.11550458 0.10494125 [97] 0.32799843 0.36328693 0.09723240 0.22248419 > > > > > cleanEx() > nameEx("scale_rasters") > ### * scale_rasters > > flush(stderr()); flush(stdout()) > > ### Name: scale_rasters > ### Title: Scale a set of rasters > ### Aliases: scale_rasters > > ### ** Examples > > # Create two example rasters > rast_a <- terra::rast( + ncol = 10, nrow = 10, + xmin = 0, xmax = 10, + ymin = 0, ymax = 10, + vals = runif(100) + ) > > rast_b <- terra::rast( + ncol = 10, nrow = 10, + xmin = 0, xmax = 10, + ymin = 0, ymax = 10, + vals = runif(100) + ) > > # Scale example rasters in a list > rast_list <- list(rast_a, rast_b) > scale_rasters(rast_list) [[1]] class : SpatRaster size : 10, 10, 1 (nrow, ncol, nlyr) resolution : 1, 1 (x, y) extent : 0, 10, 0, 10 (xmin, xmax, ymin, ymax) coord. ref. : lon/lat WGS 84 (CRS84) (OGC:CRS84) source(s) : memory name : lyr.1 min value : -1.885222 max value : 1.771622 [[2]] class : SpatRaster size : 10, 10, 1 (nrow, ncol, nlyr) resolution : 1, 1 (x, y) extent : 0, 10, 0, 10 (xmin, xmax, ymin, ymax) coord. ref. : lon/lat WGS 84 (CRS84) (OGC:CRS84) source(s) : memory name : lyr.1 min value : -1.855643 max value : 1.748284 > > > > > cleanEx() > nameEx("simulate_mpp") > ### * simulate_mpp > > flush(stderr()); flush(stdout()) > > ### Name: simulate_mpp > ### Title: Simulate a realization of a location dependent marked point > ### process > ### Aliases: simulate_mpp > > ### ** Examples > > # Specify the generating parameters of the self-correcting process > generating_parameters <- c(2, 8, .02, 2.5, 3, 1, 2.5, .2) > > # Specify an anchor point > M_n <- c(10, 14) > > # Load the raster files > raster_paths <- list.files(system.file("extdata", package = "ldmppr"), + pattern = "\\.tif$", full.names = TRUE + ) > raster_paths <- raster_paths[!grepl("_med\\.tif$", raster_paths)] > rasters <- lapply(raster_paths, terra::rast) > > # Scale the rasters > scaled_raster_list <- scale_rasters(rasters) > > # Load the example mark model > file_path <- system.file("extdata", "example_mark_model.rds", package = "ldmppr") > mark_model <- load_mark_model(file_path) > > # Simulate a realization > example_mpp <- simulate_mpp( + process = "self_correcting", + process_fit = generating_parameters, + t_min = 0, + t_max = 1, + anchor_point = M_n, + raster_list = scaled_raster_list, + scaled_rasters = TRUE, + mark_model = mark_model, + xy_bounds = c(0, 25, 0, 25), + include_comp_inds = TRUE, + competition_radius = 10, + edge_correction = "none", + thinning = TRUE, + seed = 90210 + ) self_correcting_model.cpp:975:40: runtime error: left shift of negative value -1 #0 0x7bb7fdc16bd4 in operator() /data/gannet/ripley/R/packages/tests-gcc-SAN/ldmppr/src/self_correcting_model.cpp:975 #1 0x7bb7fdc16bd4 in thin_st_fast(Rcpp::Matrix<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<14, Rcpp::PreserveStorage> const&) /data/gannet/ripley/R/packages/tests-gcc-SAN/ldmppr/src/self_correcting_model.cpp:1017 #2 0x7bb7fdc4a17a in _ldmppr_thin_st_fast /data/gannet/ripley/R/packages/tests-gcc-SAN/ldmppr/src/RcppExports.cpp:259 #3 0x000000750696 in R_doDotCall /data/gannet/ripley/R/svn/R-devel/src/main/dotcode.c:757 #4 0x000000754e6a in do_dotcall /data/gannet/ripley/R/svn/R-devel/src/main/dotcode.c:1437 #5 0x0000008cfbb2 in bcEval_loop /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:8132 #6 0x0000008bcdfb in bcEval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:7515 #7 0x00000085d722 in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:1167 #8 0x00000087346a in R_execClosure /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:2389 #9 0x00000087745a in applyClosure_core /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:2302 #10 0x00000085ddc3 in Rf_applyClosure /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:2324 #11 0x00000085ddc3 in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:1280 #12 0x00000088bc0e in do_set /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:3581 #13 0x00000085e1e6 in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:1232 #14 0x000000a02a48 in Rf_ReplIteration /data/gannet/ripley/R/svn/R-devel/src/main/main.c:264 #15 0x000000a02a48 in R_ReplConsole /data/gannet/ripley/R/svn/R-devel/src/main/main.c:317 #16 0x000000a10daa in run_Rmainloop /data/gannet/ripley/R/svn/R-devel/src/main/main.c:1235 #17 0x000000a10e42 in Rf_mainloop /data/gannet/ripley/R/svn/R-devel/src/main/main.c:1242 #18 0x00000041319f in main /data/gannet/ripley/R/svn/R-devel/src/main/Rmain.c:29 #19 0x7fb8126115f4 in __libc_start_call_main (/lib64/libc.so.6+0x35f4) (BuildId: a1dda014206b55b07f58fe8db80121b752dc3d03) #20 0x7fb8126116a7 in __libc_start_main@@GLIBC_2.34 (/lib64/libc.so.6+0x36a7) (BuildId: a1dda014206b55b07f58fe8db80121b752dc3d03) #21 0x000000413b84 in _start (/data/gannet/ripley/R/gcc-SAN3/bin/exec/R+0x413b84) (BuildId: 133ed0ef06931129bf67d773c34b2503f0a68013) > > # Plot the realization and provide a summary > plot(example_mpp, pattern_type = "simulated") > summary(example_mpp) Summary: ldmppr Simulation process: self_correcting n_points: 107 mark_range: [57.15, 639.738] time_range: [0, 0.993054] thinning: TRUE edge_correction: none xy_bounds: [0, 25, 0, 25] > > > > cleanEx() > nameEx("simulate_sc") > ### * simulate_sc > > flush(stderr()); flush(stdout()) > > ### Name: simulate_sc > ### Title: Simulate from the self-correcting model > ### Aliases: simulate_sc > > ### ** Examples > > # Specify the generating parameters of the self-correcting process > generating_parameters <- c(2, 8, .02, 2.5, 3, 1, 2.5, .2) > > # Specify an anchor point > M_n <- c(10, 14) > > # Simulate the self-correcting process > generated_locs <- simulate_sc( + t_min = 0, + t_max = 1, + sc_params = generating_parameters, + anchor_point = M_n, + xy_bounds = c(0, 25, 0, 25) + ) > > > > > cleanEx() > nameEx("toroidal_dist_matrix_optimized") > ### * toroidal_dist_matrix_optimized > > flush(stderr()); flush(stdout()) > > ### Name: toroidal_dist_matrix_optimized > ### Title: Optimized function to compute toroidal distance matrix over a > ### rectangular domain > ### Aliases: toroidal_dist_matrix_optimized > ### Keywords: internal > > ### ** Examples > > # Generate a matrix of locations > location_matrix <- matrix(c(1, 2, 3, 4, 5, 6), ncol = 2) > x_bound <- 10 > y_bound <- 10 > > # Compute the toroidal distance matrix > ldmppr:::toroidal_dist_matrix_optimized(location_matrix, x_bound, y_bound) [,1] [,2] [,3] [1,] 0.000000 1.414214 2.828427 [2,] 1.414214 0.000000 1.414214 [3,] 2.828427 1.414214 0.000000 > > > > > cleanEx() > nameEx("train_mark_model") > ### * train_mark_model > > flush(stderr()); flush(stdout()) > > ### Name: train_mark_model > ### Title: Train a flexible model for the mark distribution > ### Aliases: train_mark_model > > ### ** Examples > > # Load the small example data > data(small_example_data) > > # Load example raster data > raster_paths <- list.files(system.file("extdata", package = "ldmppr"), + pattern = "\\.tif$", full.names = TRUE + ) > raster_paths <- raster_paths[!grepl("_med\\.tif$", raster_paths)] > rasters <- lapply(raster_paths, terra::rast) > > # Scale the rasters > scaled_raster_list <- scale_rasters(rasters) > > > # Train the model > mark_model <- train_mark_model( + data = small_example_data, + raster_list = scaled_raster_list, + scaled_rasters = TRUE, + model_type = "xgboost", + xy_bounds = c(0, 25, 0, 25), + delta = 1, + parallel = FALSE, + include_comp_inds = FALSE, + competition_radius = 10, + edge_correction = "none", + selection_metric = "rmse", + cv_folds = 3, + tuning_grid_size = 2, + verbose = TRUE + ) [ldmppr::train_mark_model] Training mark model Model type: xgboost Selection metric: rmse CV folds: 3 Tuning grid size: 2 Include competition indices: no Edge correction: none Step 1/6: Preparing training data... Rows: 121 Seed: 0 Done in 0.0s. Step 2/6: Configuring parallel backend... Parallel: off Model engine threads: 1 Done in 0.1s. Step 3/6: Extracting raster covariates... Using pre-scaled rasters (scaled_rasters = TRUE). Extracted 4 raster feature(s). Done in 0.2s. Step 4/6: Building model matrix (and competition indices if requested)... Final training rows: 121 Final feature columns (incl x,y,time): 7 Done in 0.0s. Step 5/6: Fitting model (with optional CV tuning)... foreach backend: doSEQ | workers=1 Done in 1.5m. Step 6/6: Finalizing output object... Residual bootstrap stored (source=oos, transform=sqrt, bins=6, min/bin=8). Done in 3.8s. Training complete. Total time: 1.6m. > > print(mark_model) ldmppr Mark Model engine: xgboost has_fit_engine: TRUE has_xgb_raw: FALSE n_features: 7 n_rasters: 4 raster_names: Snodgrass_DEM_1m, Snodgrass_aspect_southness_1m, Snodgrass_slope_1m, Snodgrass_wetness_index_1m scaled_rasters: TRUE comp_indices: FALSE > > > > > ### *