Learn R Programming

Distance Based Measures of Spatial Structures

dbmss is an R package for simple computation of spatial statistic functions of distance to characterize the spatial structures of mapped objects, including classical ones (Ripley’s K and others) and more recent ones used by spatial economists (Duranton and Overman’s Kd, Marcon and Puech’s M). It relies on spatstat for some core calculation.

Installation

You can install the current release of the package from CRAN or the development version of dbmss from GitHub with:

# install.packages("pak")
pak::pak("EricMarcon/dbmss")

Main functions

The main functions of the package are designed to calculate distance-based measures of spatial structure. Those are non-parametric statistics able to summarize and test the spatial distribution (concentration, dispersion) of points.

The classical, topographic functions such as Ripley’s K are provided by the spatstat package and supported by dbmss for convenience.

Relative functions are available in dbmss only. These are the $M$ and $m$ and $K_d$ functions.

The bivariate $M$ function can be calculated for Q. Rosea trees around V. Americana trees:

library(dbmss)
autoplot(
  Mhat(
    paracou16, 
    ReferenceType = "V. Americana", 
    NeighborType = "Q. Rosea"
  ), 
  main = ""
)

Confidence envelopes

Confidence envelopes of various null hypotheses can be calculated. The univariate distribution of Q. Rosea is tested against the null hypothesis of random location.

autoplot(
  KdEnvelope(paracou16, ReferenceType = "Q. Rosea", Global = TRUE), 
  main = ""
)

Significant concentration is detected between about 10 and 20 meters.

Maps

Individual values of some distance-based measures can be computed and mapped.

# Calculate individual intertype M(distance) value
ReferenceType <- "V. Americana"
NeighborType <- "Q. Rosea"
fvind <- Mhat(
  paracou16, 
  r = c(0, 30), 
  ReferenceType = ReferenceType, 
  NeighborType = NeighborType, 
  Individual = TRUE
)
# Plot the point pattern with values of M(30 meters)
p16_map <- Smooth(
  paracou16, 
  fvind = fvind, 
  distance = 30,
  # Resolution
  Nbx = 512, 
  Nby = 512
)
par(mar = rep(0, 4))
plot(p16_map, main = "")
# Add the reference points to the plot
is.ReferenceType <- marks(paracou16)$PointType == ReferenceType
points(
  x = paracou16$x[is.ReferenceType], 
  y = paracou16$y[is.ReferenceType], 
  pch = 20
)
# Add contour lines
contour(p16_map, nlevels = 5, add = TRUE)

Vignettes

A quick introduction is in vignette("dbmss").

A full documentation is available on the package website. It is a continuous update of the paper published in the Journal of Statistical Software (Marcon et al., 2015).

Reference

Marcon, E., Traissac, S., Puech, F. and Lang, G. (2015). Tools to Characterize Point Patterns: dbmss for R. Journal of Statistical Software. 67(3): 1-15.

Copy Link

Version

Install

install.packages('dbmss')

Monthly Downloads

964

Version

2.11-0

License

GNU General Public License

Issues

Pull Requests

Stars

Forks

Maintainer

Eric Marcon

Last Published

June 17th, 2025

Functions in dbmss (2.11-0)

Lhat

Estimation of the L function
Lmmhat

Estimation of the Lmm function
Kmmhat

Estimation of the Kmm function
KinhomEnvelope

Estimation of the confidence envelope of the Kinhom function under its null hypothesis
LmmEnvelope

Estimation of the confidence envelope of the Lmm function under its null hypothesis
MEnvelope

Estimation of the confidence envelope of the M function under its null hypothesis
as.Dtable

Converts data to class Dtable
autoplot

ggplot methods to plot dbmss objects
dbmss-package

Distance Based Measures of Spatial Structures
as.wmppp

Converts data to class wmppp
print.dbmssEnvelope

Print a confidence envelope
rPopulationIndependenceK

Simulations of a point pattern according to the null hypothesis of population independence defined for K
dbmssEnvelope.object

Class of envelope of function values (fv)
envelope.Dtable

Computes simulation envelopes of a summary function.
Ktest

Test of a point pattern against Complete Spatial Randomness
marks

marks method for Dtable and wmppp objects
paracou16

Paracou field station plot 16, partial map
Mhat

Estimation of the M function
mhat

Estimation of the m function
mEnvelope

Estimation of the confidence envelope of the m function under its null hypothesis
wmppp

Create a Weighted, Marked, Planar Point Pattern
summary.dbmssEnvelope

Summary of a confidence envelope
wmppp.object

Class of Weighted, Marked, Planar Point Patterns
rRandomLabeling

Simulations of a point pattern according to the null hypothesis of random labeling
parallelCountNbd

Auxiliary functions to count point neighbors
rPopulationIndependenceM

Simulations of a point pattern according to the null hypothesis of population independence defined for M
gEnvelope

Estimation of the confidence envelope of the g function under its null hypothesis
Smooth.wmppp

Spatial smoothing of individual dbmss's
is.wmppp

Test whether an object is a weighted, marked, planar point pattern
ghat

Estimation of the g function
rRandomLabelingM

Simulations of a point pattern according to the null hypothesis of random labelling defined for M
rRandomPositionK

Simulations of a point pattern according to the null hypothesis of random position defined for K
spatstat generic functions

Methods for weighted, marked planar point patterns (of class wmppp) from spatstat
reexports

Objects exported from other packages
rRandomLocation

Simulations of a point pattern according to the null hypothesis of random location
CheckdbmssArguments

Checks the arguments of a function of the package dbmss
KdEnvelope

Estimation of the confidence envelope of the Kd function under its null hypothesis
GoFtest

Goodness of Fit test between a distance based measure of spatial structure and simulations of its null hypothesis
Dhat

Estimation of the D function
Kdhat

Estimation of the Kd function
KEnvelope

Estimation of the confidence envelope of the K function under its null hypothesis
DEnvelope

Estimation of the confidence envelope of the D function under its null hypothesis
Dtable

Create a Distance table object.
KmmEnvelope

Estimation of the confidence envelope of the Lmm function under its null hypothesis
LEnvelope

Estimation of the confidence envelope of the L function under its null hypothesis
GlobalEnvelope

Estimation of the global confidence interval of simulations
FillEnvelope

Transform simulation values to an fv
Khat

Estimation of the K function
Kinhomhat

Estimation of the inhomogenous K function