spesim 0.5.2
Performance
-
Vectorised environment-acceptance step.
spesim_simulate_neutral_recruitment()previously called.env_accept_prob()once per candidate point viavapply(40 calls per simulation step), with two redundant costs inside every call:-
.to_grid_index()recomputed the grid midpoints vector ((grid_vals[-1] + grid_vals[-length(grid_vals)]) / 2) on every invocation. -
.resolve_env_col()re-ran its column-name matching on every invocation.
Both costs are now eliminated. Grid midpoints (
mids_gx/mids_gy) are precomputed once at setup; the resolved column name (env_col) is stored directly ingrad_lookupat setup time. The scalar helper is replaced by a single vectorised function,.env_accept_prob_vec(), that accepts the whole candidate matrix and returns a probability vector via onefindIntervalcall and onecbind-indexed matrix lookup over all candidates at once. Self-time of the acceptance step at the benchmark configuration (N = 1,500, S = 15, hybrid model,profvisat 10 ms interval) dropped from ≈ 2,740 ms to ≈ 100 ms — a 27× reduction. -
Vectorised candidate displacement sampling. The candidate-position proposal loop —
vapplyover 40 displacements per step, each calling.propose_displacement()→.step_magnitude()→ a scalarrnorm/rexp/runif— is replaced by two batch functions:.propose_displacement_batch()and.propose_linear_pos_batch(). Each samples allbatch_sizestep magnitudes and angles in a single RNG call (e.g.stats::rnorm(40)instead of 40 ×stats::rnorm(1)), then computes candidate positions with vectorised arithmetic. Thevapplyclosure overhead and 40 individual R-level dispatches to.step_magnitude()disappear entirely. Combined with the acceptance-step improvement above, total profiled wall time for the benchmark configuration fell from 17,690 ms (v0.5.1) to 2,600 ms — a 6.8× overall speedup.
Bug fixes
-
calculate_quadrat_environment()now always returns a charactersitecolumn. Whenquadrats$quadrat_idwas integer the resultingsitecolumn inherited that type, causingdplyr::left_join()to error with “Can’t joinx$sitewith when joined against the always-charactery$site” siteproduced bycreate_abundance_matrix(). The merge argument is nowas.character(quadrats$quadrat_id), making the two functions type-consistent in all cases. This silently prevented thespesim-method-testingandspesim-ordination-dbrdavignettes from rebuilding underR CMD check.
spesim 0.5.1
Performance
C++ point-in-polygon engine. All polygon domain checks previously used
sf::st_as_sf()+sf::st_within()on every call, incurring full CRS comparison and GEOS setup overhead. They now delegate to a compiled C++ ray-casting implementation (pip_cpp), with ring coordinates extracted once and cached for the duration of any tight loop. Measured speedups at representative call sizes: 6–13× faster for batches of 1–40 points, 112× faster for the sequential-inhibition (Strauss) single-point loop.Vectorised initial community placement.
spesim_simulate_neutral_recruitment()previously sampled one position per individual inside aforloop (J individual calls tosf::st_within). Placement is now done in a single vectorised call to.sample_uniform_in_domain(), eliminating J − 1 polygon coordinate extractions and sf round-trips.Vectorised sf point construction.
.as_sfc_points()replaced alapply(sf::st_point(...))loop with a singlesf::st_as_sf()call, which is the recommended vectorised path.Shared pip tester across all helpers.
.sample_uniform_in_domain(),.simulate_strauss_points(), and.linear_pos_to_xy()all accept an optionalpip_fnargument so callers that already hold a pre-built tester avoid redundant ring-coordinate extraction.
spesim 0.4.6
Maintenance
- Added
rnaturalearthdatatoSuggeststo satisfy CRAN dependency declaration (used in vignette viarequireNamespace()).
spesim 0.4.5
Bug fixes + promised features now active
- Fixed
generate_fisher_log_series()forn_species = 1(now sums ton_individuals). - Fixed fast Strauss MH sampler state updates (accept/reject now consistent).
- Fixed Thomas and Strauss/Geyer fast helpers to be polygon-aware (bbox simulate + clip + thin/top-up).
- Implemented environmental filtering + local interspecific interactions during species assignment as documented.
- Distance–decay now aligns
site_coordstoabund_matrixby site id and uses a robust Sorensen dissimilarity for presence/absence. -
ZSM_Mis now active: when supplied as a finite value in(0, 1),SAD_MODEL = "zsm"switches from the theta-only Ewens (Chinese restaurant) sampler to a Moran-style death–birth with immigration heuristic; lowermproduces a more uneven SAD. The NEWS 0.4.2 entry below statingZSM_Mis “ignored” is superseded by this release.
spesim 0.4.2
Vignettes / neutral SAD clarification
- Updated point-process recipes vignette with an explicit explanation of the current neutral-theory SAD helper (what it can and cannot do), plus worked examples and advanced panels.
-
SAD_MODEL = "zsm"is now documented and implemented as a theta-only Ewens sampler;ZSM_Mis currently ignored (accepted for forward compatibility).
spesim 0.4.0
Runner refactor + stable results
-
spesim_run()is now the recommended, consolidated entry point and returns a stable S3 results object (spesim_result). -
run_spatial_simulation()is retained as a deprecated wrapper aroundspesim_run()for backwards compatibility. - Vignettes and README updated to reflect the new workflow.
spesim 0.3.19
Startup message
-
library(spesim)now prints the package version in the startup message.
spesim 0.3.17
Default domain shape diversity
-
create_sampling_domain()now supports multiple shape families (concave/irregular, convex hulls, ellipses/circles, and boxy rectangles/squares), and the default uses a mixed generator to better mimic real-world landscape patch shapes.
spesim 0.3.16
Default domain variability in spesim_run()
-
spesim_run()now generates a new random default domain for each run whendomain = NULLand noseedis supplied. - When
seedis supplied, the default domain is reproducible across runs.
Plotting side-effects
-
calculate_rarefaction()no longer triggers any base-graphics plotting side-effects (fixes duplicate rarefaction output when used insidegenerate_advanced_panel()).
spesim 0.3.15
Ordination teaching vignette (db-RDA)
- New vignette: constrained ordination on simulated data using distance-based RDA (db-RDA) via
vegan::capscale().
spesim 0.3.14
Build hygiene and vignette snippet checks
- Removed pkgdown/vignette build warnings by aligning vignette titles and setting
highlight: nullfor html vignettes. - Added a test to ensure all vignette code chunks are syntactically valid (
knitr::purl()+parse()).
spesim 0.3.11
Method-testing bundle helper
- New
spesim_method_test()convenience function returnsres,audit, and optional standard tables/plots for teaching and method-testing.
spesim 0.3.10
Report: configurable conceptual audit
-
generate_full_report()gainsinclude_auditandaudit_top_nto control the report’s conceptual audit section. - Report audit now runs
spesim_audit(..., diagnostics = "nn")for deterministic, lightweight behaviour.
spesim 0.3.9
Filtering audits: occupancy-aware diagnostics
-
audit_environmental_filtering()now reportsoccupancy_sites(number of quadrats with abundance > 0). - Low occupancy is flagged as
too_sparse_to_assess, helping prevent over-interpretation of noisy correlations.
spesim 0.3.8
Filtering diagnostics: plotting helper
- Add
plot_filtering_response()to visualise environment–abundance relationships for gradient-responsive species. - The plot shows the configured optimum (dashed line) and tolerance band (shaded) in natural units.
- Environmental gradients vignette updated with a filtering sanity-check section.
spesim 0.3.7
Sampling audits: effective sampling frame (area-based)
- Add
estimate_sampling_frame()and include a conservative boundary constraint summary inplacement_audit:-
safe_area_fraction= area(safe_domain)/area(domain), where safe_domain is the domain buffered inward by half the quadrat diagonal. -
buffer_dist(half-diagonal) andquadrat_sizerecorded for context.
-
- Quadrat placement audits and
audit_sampling_scheme()now report the effective sampling frame fraction alongside exclusion/rejection rates.
spesim 0.3.6
Sampling audits: standardise placement_audit
- Quadrat placement functions now attach their
placement_auditattribute via shared helpers and normalise a minimal common schema. -
audit_sampling_scheme()now validates/normalisesplacement_auditbefore reporting. - Quadrat placement vignette updated with guidance on inspecting
placement_auditfor boundary exclusion.
spesim 0.3.5
Method-testing tutor: edge-corrected spatial diagnostics (optional)
- Extend
spesim_audit()withdiagnostics = c("nn", "spatstat"). - Add optional spatstat-based, edge-corrected spatial summaries in the true irregular window:
- Ripley-style departure summary via L(r)-r (border correction)
- pair correlation function extrema (Ripley correction)
- New helper:
spesim_spatstat_diagnostics()(used internally; requiresspatstat.geom+spatstat.explore).
spesim 0.3.4
Method-testing tutor: regime classification
- Add
spesim_regime()to convert audit metrics into teaching-friendly green/amber/red regime classifications. -
spesim_audit()now includes aregimeelement andprint.spesim_audit()prints the classification summary.
spesim 0.3.3
Method-testing audits
- Add
spesim_audit()plus supporting helpers to quantify whether a realised run matches the intended qualitative regime:- nearest-neighbour spatial diagnostics per species (clustered/CSR-like/inhibited)
- environment–abundance checks for gradient-responsive species (optima/tolerances vs realised quadrat environments)
- sampling scheme boundary exclusion / rejection summaries (when available)
- Quadrat placement functions now attach a
placement_auditattribute with rejection/exclusion metrics (scheme-dependent). - The text report now includes a Conceptual audit section summarising these checks.
spesim 0.3.2
Documentation
- Add Start here article to improve pkgdown discoverability.
- Add a model card vignette clarifying what spesim does/does not model and how to interpret results.
- Add a validation & sanity checks vignette with suggested diagnostics (including optional spatstat checks).
- Clarify that the default sampling domain is synthetic/unitless (users can supply a real-world
sfdomain).
spesim 0.3.1
Usability
- New recommended high-level runner:
spesim_run()(S3 result object; better teaching workflow defaults). - New helpers for teaching/workshops:
validate_config(),list_examples(),spesim_use_example(),spesim_open_docs(). - New plotting theme:
theme_spesim(). -
plot_quadrats()now supportsshow_voronoi = "auto"/"yes"/"no"and uses tighter plotting defaults. - Config parsing errors for
c(...)vectors now include file + line context.
spesim 0.3.0
- Add
spesim_demo()convenience wrapper for teaching/quick exploration. - Improve pkgdown build cleanliness (vignette titles, NEWS headings).