Title: | Distance-Based Measures of Spatial Structures |
---|---|
Description: | Simple computation of spatial statistic functions of distance to characterize the spatial structures of mapped objects, following Marcon, Traissac, Puech, and Lang (2015) <doi:10.18637/jss.v067.c03>. Includes classical functions (Ripley's K and others) and more recent ones used by spatial economists (Duranton and Overman's Kd, Marcon and Puech's M). Relies on 'spatstat' for some core calculation. |
Authors: | Eric Marcon [aut, cre] , Gabriel Lang [aut] , Stephane Traissac [aut] , Florence Puech [aut] |
Maintainer: | Eric Marcon <[email protected]> |
License: | GNU General Public License |
Version: | 2.9-2.9001 |
Built: | 2024-11-08 18:20:15 UTC |
Source: | https://github.com/ericmarcon/dbmss |
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). Relies on spatstat for some core calculation.
Eric Marcon, Gabriel Lang, Stephane Traissac, Florence Puech
Maintainer: Eric Marcon <[email protected]>
Marcon, E., and Puech, F. (2003). Evaluating the Geographic Concentration of Industries Using Distance-Based Methods. Journal of Economic Geography, 3(4), 409-428.
Marcon, E. and Puech, F. (2010). Measures of the Geographic Concentration of Industries: Improving Distance-Based Methods. Journal of Economic Geography 10(5): 745-762.
Marcon, E., Puech F. and Traissac, S. (2012). Characterizing the relative spatial structure of point patterns. International Journal of Ecology 2012(Article ID 619281): 11.
Lang G., Marcon E. and Puech F. (2014) Distance-Based Measures of Spatial Concentration: Introducing a Relative Density Function. HAL 01082178, 1-18.
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.
Marcon, E. and Puech, F. (2017). A typology of distance-based measures of spatial concentration. Regional Science and Urban Economics. 62:56-67.
Creates an object of class "Dtable"
representing a set of points with weights and labels and the distances between them.. This is a generic method.
as.Dtable(X, ...) ## S3 method for class 'ppp' as.Dtable(X, ...) ## S3 method for class 'data.frame' as.Dtable(X, ...)
as.Dtable(X, ...) ## S3 method for class 'ppp' as.Dtable(X, ...) ## S3 method for class 'data.frame' as.Dtable(X, ...)
X |
Data to be converted into a |
... |
Extra arguments. |
This is a generic method, implemented for ppp
and data.frame
.
Data is first converted to a (wmppp.object
). Then, the distance matrix between points is calculated and the marks are kept.
An object of class "Dtable"
.
Creates a Weighted, Marked, Planar Point Pattern, i.e. an object of class "wmppp"
representing a two-dimensional point pattern with weights and labels. This is a generic method.
as.wmppp(X, ...) ## S3 method for class 'ppp' as.wmppp(X, ...) ## S3 method for class 'data.frame' as.wmppp(X, window = NULL, unitname = NULL, ...)
as.wmppp(X, ...) ## S3 method for class 'ppp' as.wmppp(X, ...) ## S3 method for class 'data.frame' as.wmppp(X, window = NULL, unitname = NULL, ...)
X |
Data to be converted into a weighted, marked, planar point pattern ( |
window |
An object of calls "owin" ( |
unitname |
Name of unit of length. Either a single character string, or a vector of two character strings giving the singular and plural forms, respectively. |
... |
Extra arguments. |
This is a generic method, implemented for ppp
and data.frame
:
If the dataset X
is an object of class "ppp" (ppp.object
), the marks are converted to point weights if they are numeric or to point types if they are factors. Default weights are set to 1, default types to "All". If marks are a dataframe with column names equal to PointType
and PointWeight
, they are not modified. Row names of the dataframe are preserved as row names of the marks, to identify points.
If the dataset X
is a dataframe, see wmppp
.
An object of class "wmppp"
.
S3 methods for the autoplot
generic.
## S3 method for class 'envelope' autoplot(object, fmla, ..., ObsColor = "black", H0Color = "red", ShadeColor = "grey75", alpha = 0.3, main = NULL, xlab = NULL, ylab = NULL, LegendLabels = NULL) ## S3 method for class 'fv' autoplot(object, fmla, ..., ObsColor = "black", H0Color = "red", ShadeColor = "grey75", alpha = 0.3, main = NULL, xlab = NULL, ylab = NULL, LegendLabels = NULL) ## S3 method for class 'wmppp' autoplot(object, ..., show.window = TRUE, MaxPointTypes = 6, Other = "Other", main = NULL, xlab = NULL, ylab = NULL, LegendLabels = NULL, labelSize = "Weight", labelColor = "Type", palette="Set1", windowColor = "black", windowFill = "transparent", alpha = 1)
## S3 method for class 'envelope' autoplot(object, fmla, ..., ObsColor = "black", H0Color = "red", ShadeColor = "grey75", alpha = 0.3, main = NULL, xlab = NULL, ylab = NULL, LegendLabels = NULL) ## S3 method for class 'fv' autoplot(object, fmla, ..., ObsColor = "black", H0Color = "red", ShadeColor = "grey75", alpha = 0.3, main = NULL, xlab = NULL, ylab = NULL, LegendLabels = NULL) ## S3 method for class 'wmppp' autoplot(object, ..., show.window = TRUE, MaxPointTypes = 6, Other = "Other", main = NULL, xlab = NULL, ylab = NULL, LegendLabels = NULL, labelSize = "Weight", labelColor = "Type", palette="Set1", windowColor = "black", windowFill = "transparent", alpha = 1)
object |
An object to be plotted. |
fmla |
An R language formula determining which variables or expressions are plotted. Either a formula object, or a string that can be parsed as a formula. See |
... |
Extra arguments, currently unused. |
ObsColor |
The color of the line representing observed values of the function. |
H0Color |
The color of the line representing the null hypothesis values of the function. |
ShadeColor |
The color of the confidence envelope. |
alpha |
The opacity of the confidence envelope (in function values) or the points (in maps), between 0 and 1. |
main |
The title of the plot. |
xlab , ylab
|
The axes labels. |
LegendLabels |
A vector of characters. The first two items describe the observed and null-hypothesis curves, the third and last item the confidence interval. To be used only in plots with two curves (typically observed and expected values). The default is 'NULL' to display the full description of functions. |
show.window |
if 'TRUE', the borders of the window containing the points are shown on the point map. |
MaxPointTypes |
The maximum number of different point types to show. If the point set contains more of them, the less frequent ones are gathered as "Other". This number must be limited for readability and not to exceed the number of colors offered by the palette. |
Other |
The name of the point types gathered as "Other". |
labelSize |
The guide of the point size legend in point maps, i.e. what the 'PointSize' mark represents. |
labelColor |
The guide of the point color legend in point maps, i.e. what the 'PointType' mark represents. |
palette |
The color palette used to display point types in maps. See |
windowColor |
The color used to draw the limits of the windows in point maps. |
windowFill |
The color used to fill the windows in point maps. |
Plots of 'wmppp' objects are a single representation of both point types and point weights.
Rectangular and polygonal windows (see owin.object
) are supported but mask windows are ignored (use the 'plot' method if necessary).
A ggplot
object.
Eric Marcon <[email protected]>, parts of the code from spatstat.explore::plot.fv
.
data(paracou16) # Keep only 20% of points to run this example X <- as.wmppp(rthin(paracou16, 0.2)) autoplot(X) # Plot the envelope (should be 1000 simulations, reduced to 20 to save time) autoplot(KdEnvelope(X, ReferenceType="Q. Rosea", NumberOfSimulations=20)) # With a formula and a compact legend autoplot(KEnvelope(X, NumberOfSimulations=20), ./(pi*r^2) ~ r, LegendLabels=c("Observed", "Expected", "Confidence\n enveloppe"))
data(paracou16) # Keep only 20% of points to run this example X <- as.wmppp(rthin(paracou16, 0.2)) autoplot(X) # Plot the envelope (should be 1000 simulations, reduced to 20 to save time) autoplot(KdEnvelope(X, ReferenceType="Q. Rosea", NumberOfSimulations=20)) # With a formula and a compact legend autoplot(KEnvelope(X, NumberOfSimulations=20), ./(pi*r^2) ~ r, LegendLabels=c("Observed", "Expected", "Confidence\n enveloppe"))
A class "dbmssEnvelope"
, i.e. a particular type of see envelope
to represent several estimates of the same function and its confidence envelope.
"dbmssEnvelope" objects are similar to envelope objects. The differences are that the risk level is chosen (instead of the simulation rank to use as the envelope), so the rank is calculated (interpolation is used if necessary), and a global envelope can be calculated following Duranton and Overman (2005).
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106
summary.dbmssEnvelope
,
KdEnvelope
,
MEnvelope
Simulates point patterns according to the null hypothesis and returns the envelope of D according to the confidence level.
DEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, Cases, Controls, Intertype = FALSE, Global = FALSE, verbose = interactive())
DEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, Cases, Controls, Intertype = FALSE, Global = FALSE, verbose = interactive())
X |
A point pattern ( |
r |
A vector of distances. If |
NumberOfSimulations |
The number of simulations to run, 100 by default. |
Alpha |
The risk level, 5% by default. |
Cases |
One of the point types |
Controls |
One of the point types. |
Intertype |
Logical; if |
Global |
Logical; if |
verbose |
Logical; if |
The only null hypothesis is random labeling: marks are distributed randomly across points.
This envelope is local by default, that is to say it is computed separately at each distance. See Loosmore and Ford (2006) for a discussion.
The global envelope is calculated by iteration: the simulations reaching one of the upper or lower values at any distance are eliminated at each step. The process is repeated until Alpha / Number of simulations simulations are dropped. The remaining upper and lower bounds at all distances constitute the global envelope. Interpolation is used if the exact ratio cannot be reached.
An envelope object (envelope
). There are methods for print and plot for this class.
The fv
contains the observed value of the function, its average simulated value and the confidence envelope.
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106.
Kenkel, N. C. (1988). Pattern of Self-Thinning in Jack Pine: Testing the Random Mortality Hypothesis. Ecology 69(4): 1017-1024.
Loosmore, N. B. and Ford, E. D. (2006). Statistical inference using the G or K point pattern spatial statistics. Ecology 87(8): 1925-1931.
Marcon, E. and F. Puech (2017). A typology of distance-based measures of spatial concentration. Regional Science and Urban Economics. 62:56-67.
data(paracou16) # Keep only 20% of points to run this example X <- as.wmppp(rthin(paracou16, 0.2)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate confidence envelope (should be 1000 simulations, reduced to 20 to save time) r <- 0:30 NumberOfSimulations <- 20 Alpha <- .05 # Plot the envelope (after normalization by pi.r^2) autoplot(DEnvelope(X, r, NumberOfSimulations, Alpha, "V. Americana", "Q. Rosea", Intertype = TRUE), ./(pi*r^2) ~ r)
data(paracou16) # Keep only 20% of points to run this example X <- as.wmppp(rthin(paracou16, 0.2)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate confidence envelope (should be 1000 simulations, reduced to 20 to save time) r <- 0:30 NumberOfSimulations <- 20 Alpha <- .05 # Plot the envelope (after normalization by pi.r^2) autoplot(DEnvelope(X, r, NumberOfSimulations, Alpha, "V. Americana", "Q. Rosea", Intertype = TRUE), ./(pi*r^2) ~ r)
Estimates the D function
Dhat(X, r = NULL, Cases, Controls = NULL, Intertype = FALSE, CheckArguments = TRUE)
Dhat(X, r = NULL, Cases, Controls = NULL, Intertype = FALSE, CheckArguments = TRUE)
X |
A weighted, marked, planar point pattern ( |
r |
A vector of distances. If |
Cases |
One of the point types. |
Controls |
One of the point types. If |
Intertype |
Logical; if |
CheckArguments |
Logical; if |
The Di function allows comparing the structure of the cases to that of the controls around cases, that is to say the comparison is made around the same points. This has been advocated by Arbia et al. (2008) and formalized by Marcon and Puech (2012).
An object of class fv
, see fv.object
, which can be plotted directly using plot.fv
.
The computation of Dhat
relies on spatstat functions Kest
and Kcross
.
Arbia, G., Espa, G. and Quah, D. (2008). A class of spatial econometric methods in the empirical analysis of clusters of firms in the space. Empirical Economics 34(1): 81-103.
Diggle, P. J. and Chetwynd, A. G. (1991). Second-Order Analysis of Spatial Clustering for Inhomogeneous Populations. Biometrics 47(3): 1155-1163.
Marcon, E. and F. Puech (2017). A typology of distance-based measures of spatial concentration. Regional Science and Urban Economics. 62:56-67.
data(paracou16) autoplot(paracou16) # Calculate D r <- 0:30 (Paracou <- Dhat(paracou16, r, "V. Americana", "Q. Rosea", Intertype = TRUE)) # Plot (after normalization by pi.r^2) autoplot(Paracou, ./(pi*r^2) ~ r)
data(paracou16) autoplot(paracou16) # Calculate D r <- 0:30 (Paracou <- Dhat(paracou16, r, "V. Americana", "Q. Rosea", Intertype = TRUE)) # Plot (after normalization by pi.r^2) autoplot(Paracou, ./(pi*r^2) ~ r)
Creates an object of class "Dtable"
representing a set of points with weights and labels and the distances between them.
Dtable(Dmatrix, PointType = NULL, PointWeight = NULL)
Dtable(Dmatrix, PointType = NULL, PointWeight = NULL)
Dmatrix |
A square matrix containing distances. |
PointType |
A vector describing the point types. Its length must correspond to the number of points. |
PointWeight |
A vector describing the point weights. Its length must correspond to the number of points. |
The distance matrix is not necessarily symmetric, so distances are understood in the common sense, not in the mathematical sense. Asymmetric distances are appropriate when paths between points are one-way only.
The points of origin are in lines, the targets in columns. The diagonal of the matrix must contain zeros (the distance between a point and itself is 0), and all other distances must be positive (they can be 0).
An object of class "Dtable"
. It is a list:
Dmatrix |
The distance matrix. |
n |
The number of points. |
marks |
A list of two items: |
# A Dtable containing two points Dmatrix <- matrix(c(0,1,1,0), nrow=2) PointType <- c("Type1", "Type2") PointWeight <- c(2,3) Dtable(Dmatrix, PointType, PointWeight)
# A Dtable containing two points Dmatrix <- matrix(c(0,1,1,0), nrow=2) PointType <- c("Type1", "Type2") PointWeight <- c(2,3) Dtable(Dmatrix, PointType, PointWeight)
Prints a useful summary of a confidence envelope of class "dbmssEnvelope"
## S3 method for class 'Dtable' envelope(Y, fun = Kest, nsim = 99, nrank = 1, ..., funargs = list(), funYargs = funargs, simulate = NULL, verbose = TRUE, savefuns = FALSE, Yname = NULL, envir.simul = NULL)
## S3 method for class 'Dtable' envelope(Y, fun = Kest, nsim = 99, nrank = 1, ..., funargs = list(), funYargs = funargs, simulate = NULL, verbose = TRUE, savefuns = FALSE, Yname = NULL, envir.simul = NULL)
Y |
An object of class |
fun |
Function that computes the desired summary statistic for |
nsim |
Number of simulated point patterns to be generated when computing the envelopes. |
nrank |
Integer. Rank of the envelope value amongst the nsim simulated values. A rank of 1 means that the minimum and maximum simulated values will be used. |
... |
Extra arguments passed to |
funargs |
A list, containing extra arguments to be passed to |
funYargs |
Optional. A list, containing extra arguments to be passed to fun when applied to the original data |
simulate |
Optional. Specifies how to generate the simulated point patterns. |
verbose |
Logical flag indicating whether to print progress reports during the simulations. |
savefuns |
Logical flag indicating whether to save all the simulated function values. |
Yname |
Character string that should be used as the name of the data |
envir.simul |
Environment in which to evaluate the expression |
This is the S3 method envelope
for Dtable
objects.
Eric Marcon <[email protected]>. Relies on the envelope
engine of spatstat.
Simulates point patterns according to the null hypothesis and returns the envelope of g according to the confidence level.
gEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType = "", NeighborType = "", SimulationType = "RandomPosition", Global = FALSE, verbose = interactive())
gEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType = "", NeighborType = "", SimulationType = "RandomPosition", Global = FALSE, verbose = interactive())
X |
A point pattern ( |
r |
A vector of distances. If |
NumberOfSimulations |
The number of simulations to run, 100 by default. |
Alpha |
The risk level, 5% by default. |
ReferenceType |
One of the point types. Default is all point types. |
NeighborType |
One of the point types. Default is all point types. |
SimulationType |
A string describing the null hypothesis to simulate. The null hypothesis may be "RandomPosition": points are drawn in a Poisson process (default); "RandomLabeling": randomizes point types, keeping locations unchanged; "PopulationIndependence": keeps reference points unchanged, shifts other point locations. |
Global |
Logical; if |
verbose |
Logical; if |
This envelope is local by default, that is to say it is computed separately at each distance. See Loosmore and Ford (2006) for a discussion.
The global envelope is calculated by iteration: the simulations reaching one of the upper or lower values at any distance are eliminated at each step. The process is repeated until Alpha / Number of simulations simulations are dropped. The remaining upper and lower bounds at all distances constitute the global envelope. Interpolation is used if the exact ratio cannot be reached.
An envelope object (envelope
). There are methods for print and plot for this class.
The fv
contains the observed value of the function, its average simulated value and the confidence envelope.
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106.
Kenkel, N. C. (1988). Pattern of Self-Thinning in Jack Pine: Testing the Random Mortality Hypothesis. Ecology 69(4): 1017-1024.
Loosmore, N. B. and Ford, E. D. (2006). Statistical inference using the G or K point pattern spatial statistics. Ecology 87(8): 1925-1931.
Marcon, E. and F. Puech (2017). A typology of distance-based measures of spatial concentration. Regional Science and Urban Economics. 62:56-67.
ghat
, rRandomPositionK
, rRandomLocation
, rPopulationIndependenceK
data(paracou16) # Keep only 20% of points to run this example X <- as.wmppp(rthin(paracou16, 0.2)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate confidence envelope (should be 1000 simulations, reduced to 10 to save time) r <- 0:40 NumberOfSimulations <- 10 # Plot the envelope autoplot(gEnvelope(X, r, NumberOfSimulations))
data(paracou16) # Keep only 20% of points to run this example X <- as.wmppp(rthin(paracou16, 0.2)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate confidence envelope (should be 1000 simulations, reduced to 10 to save time) r <- 0:40 NumberOfSimulations <- 10 # Plot the envelope autoplot(gEnvelope(X, r, NumberOfSimulations))
Estimates the g function
ghat(X, r = NULL, ReferenceType = "", NeighborType = "", CheckArguments = TRUE)
ghat(X, r = NULL, ReferenceType = "", NeighborType = "", CheckArguments = TRUE)
X |
A weighted, marked, planar point pattern ( |
r |
A vector of distances. If |
ReferenceType |
One of the point types. Default is all point types. |
NeighborType |
One of the point types. Default is all point types. |
CheckArguments |
Logical; if |
The computation of ghat
relies on spatstat function sewpcf
.
An object of class fv
, see fv.object
, which can be plotted directly using plot.fv
.
Stoyan, D. and Stoyan, H. (1994) Fractals, random shapes and point fields: methods of geometrical statistics. John Wiley and Sons.
data(paracou16) autoplot(paracou16) # Calculate g r <- 0:30 (Paracou <- ghat(paracou16, r, "Q. Rosea", "V. Americana")) # Plot autoplot(Paracou)
data(paracou16) autoplot(paracou16) # Calculate g r <- 0:30 (Paracou <- ghat(paracou16, r, "Q. Rosea", "V. Americana")) # Plot autoplot(Paracou)
Calculates the risk to reject the null hypothesis erroneously, based on the distribution of the simulations.
GoFtest(Envelope)
GoFtest(Envelope)
Envelope |
An envelope object ( |
This test was introduced by Diggle(1983) and extensively developped by Loosmore and Ford (2006) for K, and applied to M by Marcon et al. (2012).
A p-value.
No support exists in the literature to apply the GoF test to non-cumulative functions (g, Kd...).
Ktest
is a much better test (it does not rely on simulations) but it is limited to the K function against complete spatial randomness (CSR) in a rectangle window.
Diggle, P. J. (1983). Statistical analysis of spatial point patterns. Academic Press, London. 148 p.
Loosmore, N. B. and Ford, E. D. (2006). Statistical inference using the G or K point pattern spatial statistics. Ecology 87(8): 1925-1931.
Marcon, E., F. Puech and S. Traissac (2012). Characterizing the relative spatial structure of point patterns. International Journal of Ecology 2012(Article ID 619281): 11.
# Simulate a Matern (Neyman Scott) point pattern nclust <- function(x0, y0, radius, n) { return(runifdisc(n, radius, centre=c(x0, y0))) } X <- rNeymanScott(20, 0.2, nclust, radius=0.3, n=10) autoplot(as.wmppp(X)) # Calculate confidence envelope (should be 1000 simulations, reduced to 50 to save time) r <- seq(0, 0.3, 0.01) NumberOfSimulations <- 50 Alpha <- .10 Envelope <- KEnvelope(as.wmppp(X), r, NumberOfSimulations, Alpha) autoplot(Envelope, ./(pi*r^2) ~ r) # GoF test. Power is correct if enough simulations are run (say >1000). paste("p-value =", GoFtest(Envelope))
# Simulate a Matern (Neyman Scott) point pattern nclust <- function(x0, y0, radius, n) { return(runifdisc(n, radius, centre=c(x0, y0))) } X <- rNeymanScott(20, 0.2, nclust, radius=0.3, n=10) autoplot(as.wmppp(X)) # Calculate confidence envelope (should be 1000 simulations, reduced to 50 to save time) r <- seq(0, 0.3, 0.01) NumberOfSimulations <- 50 Alpha <- .10 Envelope <- KEnvelope(as.wmppp(X), r, NumberOfSimulations, Alpha) autoplot(Envelope, ./(pi*r^2) ~ r) # GoF test. Power is correct if enough simulations are run (say >1000). paste("p-value =", GoFtest(Envelope))
Check whether its argument is an object of class "wmppp" (wmppp.object
).
is.wmppp(X)
is.wmppp(X)
X |
Any object |
TRUE
if X
is a weighted, marked, planar point pattern, otherwise FALSE
.
Simulates point patterns according to the null hypothesis and returns the envelope of Kd according to the confidence level.
KdEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType, NeighborType = ReferenceType, Weighted = FALSE, Original = TRUE, Approximate = ifelse(X$n < 10000, 0, 1), Adjust = 1, MaxRange = "ThirdW", StartFromMinR = FALSE, SimulationType = "RandomLocation", Global = FALSE, verbose = interactive())
KdEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType, NeighborType = ReferenceType, Weighted = FALSE, Original = TRUE, Approximate = ifelse(X$n < 10000, 0, 1), Adjust = 1, MaxRange = "ThirdW", StartFromMinR = FALSE, SimulationType = "RandomLocation", Global = FALSE, verbose = interactive())
X |
A point pattern ( |
r |
A vector of distances. If |
NumberOfSimulations |
The number of simulations to run, 100 by default. |
Alpha |
The risk level, 5% by default. |
ReferenceType |
One of the point types. |
NeighborType |
One of the point types. By default, the same as reference type. |
Weighted |
Logical; if |
Original |
Logical; if |
Approximate |
if not 0 (1 is a good choice), exact distances between pairs of points are rounded to 1024 times |
Adjust |
Force the automatically selected bandwidth (following Silverman, 1986) to be multiplied by |
MaxRange |
The maximum value of |
StartFromMinR |
Logical; if |
SimulationType |
A string describing the null hypothesis to simulate. The null hypothesis may be "RandomLocation": points are redistributed on the actual locations (default); "RandomLabeling": randomizes point types, keeping locations and weights unchanged; "PopulationIndependence": keeps reference points unchanged, randomizes other point locations. |
Global |
Logical; if |
verbose |
Logical; if |
This envelope is local by default, that is to say it is computed separately at each distance. See Loosmore and Ford (2006) for a discussion.
The global envelope is calculated by iteration: the simulations reaching one of the upper or lower values at any distance are eliminated at each step. The process is repeated until Alpha / Number of simulations simulations are dropped. The remaining upper and lower bounds at all distances constitute the global envelope. Interpolation is used if the exact ratio cannot be reached.
An envelope object (envelope
). There are methods for print and plot for this class.
The fv
contains the observed value of the function, its average simulated value and the confidence envelope.
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106.
Kenkel, N. C. (1988). Pattern of Self-Thinning in Jack Pine: Testing the Random Mortality Hypothesis. Ecology 69(4): 1017-1024.
Loosmore, N. B. and Ford, E. D. (2006). Statistical inference using the G or K point pattern spatial statistics. Ecology 87(8): 1925-1931.
Marcon, E. and F. Puech (2017). A typology of distance-based measures of spatial concentration. Regional Science and Urban Economics. 62:56-67.
Scholl, T. and Brenner, T. (2015) Optimizing distance-based methods for large data sets, Journal of Geographical Systems 17(4): 333-351.
Silverman, B. W. (1986). Density estimation for statistics and data analysis. Chapman and Hall, London.
data(paracou16) autoplot(paracou16[marks(paracou16)$PointType=="Q. Rosea"]) # Calculate confidence envelope plot(KdEnvelope(paracou16, , ReferenceType="Q. Rosea", Global=TRUE)) # Center of the confidence interval Kdhat(paracou16, ReferenceType="") -> kd lines(kd$Kd ~ kd$r, lty=3, col="green")
data(paracou16) autoplot(paracou16[marks(paracou16)$PointType=="Q. Rosea"]) # Calculate confidence envelope plot(KdEnvelope(paracou16, , ReferenceType="Q. Rosea", Global=TRUE)) # Center of the confidence interval Kdhat(paracou16, ReferenceType="") -> kd lines(kd$Kd ~ kd$r, lty=3, col="green")
Estimates the Kd function
Kdhat(X, r = NULL, ReferenceType, NeighborType = ReferenceType, Weighted = FALSE, Original = TRUE, Approximate = ifelse(X$n < 10000, 0, 1), Adjust = 1, MaxRange = "ThirdW", StartFromMinR = FALSE, CheckArguments = TRUE)
Kdhat(X, r = NULL, ReferenceType, NeighborType = ReferenceType, Weighted = FALSE, Original = TRUE, Approximate = ifelse(X$n < 10000, 0, 1), Adjust = 1, MaxRange = "ThirdW", StartFromMinR = FALSE, CheckArguments = TRUE)
X |
A weighted, marked planar point pattern ( |
r |
A vector of distances. If |
ReferenceType |
One of the point types. If "", all points are considered (this is not the default value; |
NeighborType |
One of the point types. By default, the same as reference type. |
Weighted |
Logical; if |
Original |
Logical; if |
Approximate |
if not 0 (1 is a good choice), exact distances between pairs of points are rounded to 1024 times |
Adjust |
Force the automatically selected bandwidth (following |
MaxRange |
The maximum value of |
StartFromMinR |
Logical; if |
CheckArguments |
Logical; if |
Kd is a density, absolute measure of a point pattern structure. Kd is computed efficiently by building a matrix of distances between point pairs and calculating the density of their distribution (the default values of r
are those of the density
function). The kernel estimator is Gaussian.
The weighted Kd function has been named Kemp (emp is for employees) by Duranton and Overman (2005).
If X
is not a Dtable
object, the maximum value of r
is obtained from the geometry of the window rather than caculating the median distance between points as suggested by Duranton and Overman (2005) to save (a lot of) calculation time.
An object of class fv
, see fv.object
, which can be plotted directly using plot.fv
.
Estimating Kd relies on calculating distances, exactly or approximately (if Approximate
is not 0).
Then distances are smoothed by estimating their probability density.
Reflection is used to estimate density close to the lowest distance, that is the minimum observed distance (if StartFromMinR
is TRUE
) or 0: all distances below 4 times the estimation kernel bandwith apart from the lowest distance are duplicated (symmetrically with respect to the lowest distance) to avoid edge effects (underestimation of the density close to the lowest distance).
Density estimation heavily relies on the bandwith.
Starting from version 2.7, the optimal bandwith is computed from the distribution of distances between pairs of points up to twice the maximum distance considered.
The consequence is that choosing a smaller range of distances in argument r
results in less smoothed values.
The default values (
r = NULL
, MaxRange = "ThirdW"
) are such that almost all the pairs of points (except those more than 2/3 of the window diameter apart) are taken into account to determine the bandwith.
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106.
Marcon, E. and F. Puech (2017). A typology of distance-based measures of spatial concentration. Regional Science and Urban Economics. 62:56-67.
Scholl, T. and Brenner, T. (2015) Optimizing distance-based methods for large data sets, Journal of Geographical Systems 17(4): 333-351.
Sheather, S. J. and Jones, M. C. (1991) A reliable data-based bandwidth selection method for kernel density estimation. Journal of the Royal Statistical Society series B, 53, 683-690.
Silverman, B. W. (1986). Density estimation for statistics and data analysis. Chapman and Hall, London.
data(paracou16) autoplot(paracou16) # Calculate Kd (Paracou <- Kdhat(paracou16, , "Q. Rosea", "V. Americana")) # Plot autoplot(Paracou)
data(paracou16) autoplot(paracou16) # Calculate Kd (Paracou <- Kdhat(paracou16, , "Q. Rosea", "V. Americana")) # Plot autoplot(Paracou)
Simulates point patterns according to the null hypothesis and returns the envelope of K according to the confidence level.
KEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType = "", NeighborType = ReferenceType, SimulationType = "RandomPosition", Precision = 0, Global = FALSE, verbose = interactive())
KEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType = "", NeighborType = ReferenceType, SimulationType = "RandomPosition", Precision = 0, Global = FALSE, verbose = interactive())
X |
A point pattern ( |
r |
A vector of distances. If |
NumberOfSimulations |
The number of simulations to run, 100 by default. |
Alpha |
The risk level, 5% by default. |
ReferenceType |
One of the point types. Default is all point types. |
NeighborType |
One of the point types. By default, the same as reference type. |
SimulationType |
A string describing the null hypothesis to simulate. The null hypothesis may be "RandomPosition": points are drawn in a Poisson process (default); "RandomLabeling": randomizes point types, keeping locations unchanged; "PopulationIndependence": keeps reference points unchanged, shifts other point locations. |
Precision |
Accuracy of point coordinates, measured as a part of distance unit. See |
Global |
Logical; if |
verbose |
Logical; if |
This envelope is local by default, that is to say it is computed separately at each distance. See Loosmore and Ford (2006) for a discussion.
The global envelope is calculated by iteration: the simulations reaching one of the upper or lower values at any distance are eliminated at each step. The process is repeated until Alpha / Number of simulations simulations are dropped. The remaining upper and lower bounds at all distances constitute the global envelope. Interpolation is used if the exact ratio cannot be reached.
An envelope object (envelope
). There are methods for print and plot for this class.
The fv
contains the observed value of the function, its average simulated value and the confidence envelope.
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106.
Kenkel, N. C. (1988). Pattern of Self-Thinning in Jack Pine: Testing the Random Mortality Hypothesis. Ecology 69(4): 1017-1024.
Loosmore, N. B. and Ford, E. D. (2006). Statistical inference using the G or K point pattern spatial statistics. Ecology 87(8): 1925-1931.
Marcon, E. and F. Puech (2017). A typology of distance-based measures of spatial concentration. Regional Science and Urban Economics. 62:56-67.
Silverman, B. W. (1986). Density estimation for statistics and data analysis. Chapman and Hall, London.
Khat
, rRandomPositionK
, rRandomLocation
, rPopulationIndependenceK
data(paracou16) # Keep only 20% of points to run this example X <- as.wmppp(rthin(paracou16, 0.2)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate confidence envelope (should be 1000 simulations, reduced to 20 to save time) r <- 0:30 NumberOfSimulations <- 20 # Plot the envelope autoplot(KEnvelope(X, r, NumberOfSimulations), ./(pi*r^2) ~ r)
data(paracou16) # Keep only 20% of points to run this example X <- as.wmppp(rthin(paracou16, 0.2)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate confidence envelope (should be 1000 simulations, reduced to 20 to save time) r <- 0:30 NumberOfSimulations <- 20 # Plot the envelope autoplot(KEnvelope(X, r, NumberOfSimulations), ./(pi*r^2) ~ r)
Estimates the K function
Khat(X, r = NULL, ReferenceType = "", NeighborType = ReferenceType, CheckArguments = TRUE)
Khat(X, r = NULL, ReferenceType = "", NeighborType = ReferenceType, CheckArguments = TRUE)
X |
A weighted, marked, planar point pattern ( |
r |
A vector of distances. If |
ReferenceType |
One of the point types. Default is all point types. |
NeighborType |
One of the point types. By default, the same as reference type. |
CheckArguments |
Logical; if |
K is a cumulative, topographic measure of a point pattern structure.
An object of class fv
, see fv.object
, which can be plotted directly using plot.fv
.
The computation of Khat
relies on spatstat functions Kest
and Kcross
.
Ripley, B. D. (1976). The Foundations of Stochastic Geometry. Annals of Probability 4(6): 995-998.
Ripley, B. D. (1977). Modelling Spatial Patterns. Journal of the Royal Statistical Society B 39(2): 172-212.
data(paracou16) autoplot(paracou16) # Calculate K r <- 0:30 (Paracou <- Khat(paracou16, r)) # Plot (after normalization by pi.r^2) autoplot(Paracou, ./(pi*r^2) ~ r)
data(paracou16) autoplot(paracou16) # Calculate K r <- 0:30 (Paracou <- Khat(paracou16, r)) # Plot (after normalization by pi.r^2) autoplot(Paracou, ./(pi*r^2) ~ r)
Simulates point patterns according to the null hypothesis and returns the envelope of Kinhom according to the confidence level.
KinhomEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType = "", lambda = NULL, SimulationType = "RandomPosition", Global = FALSE, verbose = interactive())
KinhomEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType = "", lambda = NULL, SimulationType = "RandomPosition", Global = FALSE, verbose = interactive())
X |
A point pattern ( |
r |
A vector of distances. If |
NumberOfSimulations |
The number of simulations to run. |
Alpha |
The risk level. |
ReferenceType |
One of the point types. Default is all point types. |
lambda |
An estimation of the point pattern density, obtained by the |
SimulationType |
A string describing the null hypothesis to simulate. The null hypothesis, may be
"RandomPosition": points are drawn in an inhomogenous Poisson process (intensity is either |
Global |
Logical; if |
verbose |
Logical; if |
The random location null hypothesis is that of Duranton and Overman (2005). It is appropriate to test the univariate Kinhom function of a single point type, redistributing it over all point locations. It allows fixing lambda along simulations so the warning message can be ignored.
The random labeling hypothesis is appropriate for the bivariate Kinhom function.
The population independence hypothesis is that of Marcon and Puech (2010).
This envelope is local by default, that is to say it is computed separately at each distance. See Loosmore and Ford (2006) for a discussion.
The global envelope is calculated by iteration: the simulations reaching one of the upper or lower values at any distance are eliminated at each step. The process is repeated until Alpha / Number of simulations simulations are dropped. The remaining upper and lower bounds at all distances constitute the global envelope. Interpolation is used if the exact ratio cannot be reached.
An envelope object (envelope
). There are methods for print and plot for this class.
The fv
contains the observed value of the function, its average simulated value and the confidence envelope.
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106.
Kenkel, N. C. (1988). Pattern of Self-Thinning in Jack Pine: Testing the Random Mortality Hypothesis. Ecology 69(4): 1017-1024.
Loosmore, N. B. and Ford, E. D. (2006). Statistical inference using the G or K point pattern spatial statistics. Ecology 87(8): 1925-1931.
Marcon, E. and Puech, F. (2010). Measures of the Geographic Concentration of Industries: Improving Distance-Based Methods. Journal of Economic Geography 10(5): 745-762.
Marcon, E. and F. Puech (2017). A typology of distance-based measures of spatial concentration. Regional Science and Urban Economics. 62:56-67.
data(paracou16) # Keep only 20% of points to run this example X <- as.wmppp(rthin(paracou16, 0.2)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Density of all trees lambda <- density.ppp(X, bw.diggle(X)) plot(lambda) V.americana <- X[marks(X)$PointType=="V. Americana"] plot(V.americana, add=TRUE) # Calculate Kinhom according to the density of all trees # and confidence envelope (should be 1000 simulations, reduced to 4 to save time) r <- 0:30 NumberOfSimulations <- 4 Alpha <- .10 autoplot(KinhomEnvelope(X, r,NumberOfSimulations, Alpha, , SimulationType="RandomPosition", lambda=lambda), ./(pi*r^2) ~ r)
data(paracou16) # Keep only 20% of points to run this example X <- as.wmppp(rthin(paracou16, 0.2)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Density of all trees lambda <- density.ppp(X, bw.diggle(X)) plot(lambda) V.americana <- X[marks(X)$PointType=="V. Americana"] plot(V.americana, add=TRUE) # Calculate Kinhom according to the density of all trees # and confidence envelope (should be 1000 simulations, reduced to 4 to save time) r <- 0:30 NumberOfSimulations <- 4 Alpha <- .10 autoplot(KinhomEnvelope(X, r,NumberOfSimulations, Alpha, , SimulationType="RandomPosition", lambda=lambda), ./(pi*r^2) ~ r)
Estimates the Kinhom function
Kinhomhat(X, r = NULL, ReferenceType = "", lambda = NULL, CheckArguments = TRUE)
Kinhomhat(X, r = NULL, ReferenceType = "", lambda = NULL, CheckArguments = TRUE)
X |
A weighted, marked, planar point pattern ( |
r |
A vector of distances. If |
ReferenceType |
One of the point types. Default is all point types. |
lambda |
An estimation of the point pattern density, obtained by the |
CheckArguments |
Logical; if |
Kinhom is a cumulative, topographic measure of an inhomogenous point pattern structure.
By default, density estimation is performed at points by density.ppp
using the optimal bandwith (bw.diggle
). It can be calculated separately (see example), including at pixels if the point pattern is too large for the default estimation to succeed, and provided as the argument lambda
:
Arbia et al. (2012) for example use another point pattern as a reference to estimate density.
Bivariate Kinhom is not currently supported.
An object of class fv
, see fv.object
, which can be plotted directly using plot.fv
.
The computation of Kinhomhat
relies on spatstat functions Kinhom
, density.ppp
and bw.diggle
.
Baddeley, A. J., J. Moller, et al. (2000). Non- and semi-parametric estimation of interaction in inhomogeneous point patterns. Statistica Neerlandica 54(3): 329-350.
Arbia, G., G. Espa, et al. (2012). Clusters of firms in an inhomogeneous space: The high-tech industries in Milan. Economic Modelling 29(1): 3-11.
data(paracou16) # Density of all trees lambda <- density.ppp(paracou16, bw.diggle(paracou16)) plot(lambda) # Reduce the point pattern to one type of trees V.americana <- paracou16[marks(paracou16)$PointType=="V. Americana"] plot(V.americana, add=TRUE) # Calculate Kinhom according to the density of all trees r <- 0:30 autoplot(Kinhomhat(paracou16, r, "V. Americana", lambda), ./(pi*r^2) ~ r)
data(paracou16) # Density of all trees lambda <- density.ppp(paracou16, bw.diggle(paracou16)) plot(lambda) # Reduce the point pattern to one type of trees V.americana <- paracou16[marks(paracou16)$PointType=="V. Americana"] plot(V.americana, add=TRUE) # Calculate Kinhom according to the density of all trees r <- 0:30 autoplot(Kinhomhat(paracou16, r, "V. Americana", lambda), ./(pi*r^2) ~ r)
Simulates point patterns according to the null hypothesis and returns the envelope of Lmm according to the confidence level.
KmmEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType = "", Global = FALSE, verbose = interactive())
KmmEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType = "", Global = FALSE, verbose = interactive())
X |
A point pattern ( |
r |
A vector of distances. If |
NumberOfSimulations |
The number of simulations to run, 100 by default. |
Alpha |
The risk level, 5% by default. |
ReferenceType |
One of the point types. Others are ignored. Default is all point types. |
Global |
Logical; if |
verbose |
Logical; if |
This envelope is local by default, that is to say it is computed separately at each distance. See Loosmore and Ford (2006) for a discussion.
The global envelope is calculated by iteration: the simulations reaching one of the upper or lower values at any distance are eliminated at each step. The process is repeated until Alpha / Number of simulations simulations are dropped. The remaining upper and lower bounds at all distances constitute the global envelope. Interpolation is used if the exact ratio cannot be reached.
An envelope object (envelope
). There are methods for print and plot for this class.
The fv
contains the observed value of the function, its average simulated value and the confidence envelope.
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106.
Kenkel, N. C. (1988). Pattern of Self-Thinning in Jack Pine: Testing the Random Mortality Hypothesis. Ecology 69(4): 1017-1024.
Loosmore, N. B. and Ford, E. D. (2006). Statistical inference using the G or K point pattern spatial statistics. Ecology 87(8): 1925-1931.
Marcon, E. and F. Puech (2017). A typology of distance-based measures of spatial concentration. Regional Science and Urban Economics. 62:56-67.
data(paracou16) # Keep only 20% of points to run this example X <- as.wmppp(rthin(paracou16, 0.2)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate confidence envelope (should be 1000 simulations, reduced to 4 to save time) r <- seq(0, 30, 2) NumberOfSimulations <- 4 Alpha <- .10 autoplot(KmmEnvelope(X, r, NumberOfSimulations, Alpha), ./(pi*r^2) ~ r)
data(paracou16) # Keep only 20% of points to run this example X <- as.wmppp(rthin(paracou16, 0.2)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate confidence envelope (should be 1000 simulations, reduced to 4 to save time) r <- seq(0, 30, 2) NumberOfSimulations <- 4 Alpha <- .10 autoplot(KmmEnvelope(X, r, NumberOfSimulations, Alpha), ./(pi*r^2) ~ r)
Estimates of the Kmm function
Kmmhat(X, r = NULL, ReferenceType = "", CheckArguments = TRUE)
Kmmhat(X, r = NULL, ReferenceType = "", CheckArguments = TRUE)
X |
A weighted, marked, planar point pattern ( |
r |
A vector of distances. If |
ReferenceType |
One of the point types. Others are ignored. Default is all point types. |
CheckArguments |
Logical; if |
The Kmm function is used to test the independence of marks.
An object of class fv
, see fv.object
, which can be plotted directly using plot.fv
.
The function is computed using markcorrint
in spatstat.
Penttinen, A., Stoyan, D. and Henttonen, H. M. (1992). Marked Point Processes in Forest Statistics. Forest Science 38(4): 806-824.
Penttinen, A. (2006). Statistics for Marked Point Patterns. in The Yearbook of the Finnish Statistical Society. The Finnish Statistical Society, Helsinki: 70-91.
Lmmhat
, LmmEnvelope
, markcorrint
data(paracou16) # Keep only 50% of points to run this example X <- as.wmppp(rthin(paracou16, 0.5)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate Kmm r <- seq(0, 30, 2) (Paracou <- Kmmhat(X, r)) # Plot autoplot(Paracou, ./(pi*r^2) ~ r)
data(paracou16) # Keep only 50% of points to run this example X <- as.wmppp(rthin(paracou16, 0.5)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate Kmm r <- seq(0, 30, 2) (Paracou <- Kmmhat(X, r)) # Plot autoplot(Paracou, ./(pi*r^2) ~ r)
Tests the point pattern against CSR using values of the K function
Ktest(X, r)
Ktest(X, r)
X |
A point pattern ( |
r |
A vector of distances. |
The test returns the risk to reject CSR erroneously, i.e. the p-value of the test, based on the distribution of the K function.
If r
includes 0, it will be silently removed because no neighbor point can be found at distance 0.
The longer r
, the more accurate the test is in theory but at the cost of computation time first, and of computation accuracy then because a matrix of size the length of r
must be inverted.
10 values in r
seems to be a reasonable choice.
A p-value.
Gabriel Lang <[email protected]>, Eric Marcon<[email protected]>
Lang, G. and Marcon, E. (2013). Testing randomness of spatial point patterns with the Ripley statistic. ESAIM: Probability and Statistics. 17: 767-788.
Marcon, E., S. Traissac, and Lang, G. (2013). A Statistical Test for Ripley's Function Rejection of Poisson Null Hypothesis. ISRN Ecology 2013(Article ID 753475): 9.
# Simulate a Matern (Neyman Scott) point pattern nclust <- function(x0, y0, radius, n) { return(runifdisc(n, radius, centre=c(x0, y0))) } X <- rNeymanScott(20, 0.1, nclust, radius=0.2, n=5) autoplot(as.wmppp(X)) # Test it Ktest(X, r=seq(0.1, .5, .1))
# Simulate a Matern (Neyman Scott) point pattern nclust <- function(x0, y0, radius, n) { return(runifdisc(n, radius, centre=c(x0, y0))) } X <- rNeymanScott(20, 0.1, nclust, radius=0.2, n=5) autoplot(as.wmppp(X)) # Test it Ktest(X, r=seq(0.1, .5, .1))
Simulates point patterns according to the null hypothesis and returns the envelope of L according to the confidence level.
LEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType = "", NeighborType = "", SimulationType = "RandomPosition", Precision = 0, Global = FALSE, verbose = interactive())
LEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType = "", NeighborType = "", SimulationType = "RandomPosition", Precision = 0, Global = FALSE, verbose = interactive())
X |
A point pattern ( |
r |
A vector of distances. If |
NumberOfSimulations |
The number of simulations to run, 100 by default. |
Alpha |
The risk level, 5% by default. |
ReferenceType |
One of the point types. Default is all point types. |
NeighborType |
One of the point types. Default is all point types. |
SimulationType |
A string describing the null hypothesis to simulate. The null hypothesis may be "RandomPosition": points are drawn in a Poisson process (default); "RandomLabeling": randomizes point types, keeping locations unchanged; "PopulationIndependence": keeps reference points unchanged, randomizes other point locations. |
Precision |
Accuracy of point coordinates, measured as a part of distance unit. See |
Global |
Logical; if |
verbose |
Logical; if |
This envelope is local by default, that is to say it is computed separately at each distance. See Loosmore and Ford (2006) for a discussion.
The global envelope is calculated by iteration: the simulations reaching one of the upper or lower values at any distance are eliminated at each step. The process is repeated until Alpha / Number of simulations simulations are dropped. The remaining upper and lower bounds at all distances constitute the global envelope. Interpolation is used if the exact ratio cannot be reached.
An envelope object (envelope
). There are methods for print and plot for this class.
The fv
contains the observed value of the function, its average simulated value and the confidence envelope.
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106.
Kenkel, N. C. (1988). Pattern of Self-Thinning in Jack Pine: Testing the Random Mortality Hypothesis. Ecology 69(4): 1017-1024.
Loosmore, N. B. and Ford, E. D. (2006). Statistical inference using the G or K point pattern spatial statistics. Ecology 87(8): 1925-1931.
Marcon, E. and F. Puech (2017). A typology of distance-based measures of spatial concentration. Regional Science and Urban Economics. 62:56-67.
data(paracou16) # Keep only 20% of points to run this example X <- as.wmppp(rthin(paracou16, 0.2)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate confidence envelope (should be 1000 simulations, reduced to 20 to save time) r <- 0:30 NumberOfSimulations <- 20 # Plot the envelope autoplot(LEnvelope(X, r, NumberOfSimulations))
data(paracou16) # Keep only 20% of points to run this example X <- as.wmppp(rthin(paracou16, 0.2)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate confidence envelope (should be 1000 simulations, reduced to 20 to save time) r <- 0:30 NumberOfSimulations <- 20 # Plot the envelope autoplot(LEnvelope(X, r, NumberOfSimulations))
Estimates the L function
Lhat(X, r = NULL, ReferenceType = "", NeighborType = "", CheckArguments = TRUE)
Lhat(X, r = NULL, ReferenceType = "", NeighborType = "", CheckArguments = TRUE)
X |
A weighted, marked, planar point pattern ( |
r |
A vector of distances. If |
ReferenceType |
One of the point types. Default is all point types. |
NeighborType |
One of the point types. Default is all point types. |
CheckArguments |
Logical; if |
L is the normalized version of K: .
An object of class fv
, see fv.object
, which can be plotted directly using plot.fv
.
L was originally defined as . It has been used as
in a part of the literature because this normalization is easier to plot.
Besag, J. E. (1977). Comments on Ripley's paper. Journal of the Royal Statistical Society B 39(2): 193-195.
data(paracou16) autoplot(paracou16) # Calculate L r <- 0:30 (Paracou <- Lhat(paracou16, r)) # Plot autoplot(Paracou)
data(paracou16) autoplot(paracou16) # Calculate L r <- 0:30 (Paracou <- Lhat(paracou16, r)) # Plot autoplot(Paracou)
Simulates point patterns according to the null hypothesis and returns the envelope of Lmm according to the confidence level.
LmmEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType = "", Global = FALSE, verbose = interactive())
LmmEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType = "", Global = FALSE, verbose = interactive())
X |
A weighted, marked, planar point pattern ( |
r |
A vector of distances. If |
NumberOfSimulations |
The number of simulations to run, 100 by default. |
Alpha |
The risk level, 5% by default. |
ReferenceType |
One of the point types. Others are ignored. Default is all point types. |
Global |
Logical; if |
verbose |
Logical; if |
This envelope is local by default, that is to say it is computed separately at each distance. See Loosmore and Ford (2006) for a discussion.
The global envelope is calculated by iteration: the simulations reaching one of the upper or lower values at any distance are eliminated at each step. The process is repeated until Alpha / Number of simulations simulations are dropped. The remaining upper and lower bounds at all distances constitute the global envelope. Interpolation is used if the exact ratio cannot be reached.
An envelope object (envelope
). There are methods for print and plot for this class.
The fv
contains the observed value of the function, its average simulated value and the confidence envelope.
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106.
Kenkel, N. C. (1988). Pattern of Self-Thinning in Jack Pine: Testing the Random Mortality Hypothesis. Ecology 69(4): 1017-1024.
Loosmore, N. B. and Ford, E. D. (2006). Statistical inference using the G or K point pattern spatial statistics. Ecology 87(8): 1925-1931.
Marcon, E. and F. Puech (2017). A typology of distance-based measures of spatial concentration. Regional Science and Urban Economics. 62:56-67.
data(paracou16) # Keep only 20% of points to run this example X <- as.wmppp(rthin(paracou16, 0.2)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate confidence envelope (should be 1000 simulations, reduced to 4 to save time) r <- seq(0, 30, 2) NumberOfSimulations <- 4 Alpha <- .10 autoplot(LmmEnvelope(X, r, NumberOfSimulations, Alpha))
data(paracou16) # Keep only 20% of points to run this example X <- as.wmppp(rthin(paracou16, 0.2)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate confidence envelope (should be 1000 simulations, reduced to 4 to save time) r <- seq(0, 30, 2) NumberOfSimulations <- 4 Alpha <- .10 autoplot(LmmEnvelope(X, r, NumberOfSimulations, Alpha))
Estimates the Lmm function
Lmmhat(X, r = NULL, ReferenceType = "", CheckArguments = TRUE)
Lmmhat(X, r = NULL, ReferenceType = "", CheckArguments = TRUE)
X |
A weighted, marked, planar point pattern ( |
r |
A vector of distances. If |
ReferenceType |
One of the point types. Others are ignored. Default is all point types. |
CheckArguments |
Logical; if |
Lmm is the normalized version of Kmm: .
An object of class fv
, see fv.object
, which can be plotted directly using plot.fv
.
Penttinen, A., Stoyan, D. and Henttonen, H. M. (1992). Marked Point Processes in Forest Statistics. Forest Science 38(4): 806-824.
Espa, G., Giuliani, D. and Arbia, G. (2010). Weighting Ripley's K-function to account for the firm dimension in the analysis of spatial concentration. Discussion Papers, 12/2010. Universita di Trento, Trento: 26.
data(paracou16) # Keep only 50% of points to run this example X <- as.wmppp(rthin(paracou16, 0.5)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate Lmm r <- seq(0, 30, 2) (Paracou <- Lmmhat(X, r)) # Plot autoplot(Paracou)
data(paracou16) # Keep only 50% of points to run this example X <- as.wmppp(rthin(paracou16, 0.5)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate Lmm r <- seq(0, 30, 2) (Paracou <- Lmmhat(X, r)) # Plot autoplot(Paracou)
S3 methods for the marks
generic.
## S3 method for class 'Dtable' marks(x, ...) ## S3 replacement method for class 'Dtable' marks(x, ...) <- value ## S3 replacement method for class 'wmppp' marks(x, ..., dfok = TRUE, drop = TRUE) <- value
## S3 method for class 'Dtable' marks(x, ...) ## S3 replacement method for class 'Dtable' marks(x, ...) <- value ## S3 replacement method for class 'wmppp' marks(x, ..., dfok = TRUE, drop = TRUE) <- value
x |
A |
... |
Extra arguments, currently unused. |
value |
The value to set. |
dfok |
Ignored. |
drop |
Ignored. |
These functions extract or modify the marks of a Dtable
.
'marks<-.wmppp()' just calls 'marks<-.ppp()' and keeps the class of the wmppp object. The conformity of the marks with the definition of the class "wmppp", i.e. a dataframe with columns "PointType" and "PointWeight" of the same length as the number of points, is not checked.
A dataframe with columns "PointType" and "PointWeight".
Eric Marcon <[email protected]>
# A Dtable containing two points Dmatrix <- matrix(c(0,1,1,0), nrow=2) PointType <- c("Type1", "Type2") PointWeight <- c(2,3) X <- Dtable(Dmatrix, PointType, PointWeight) # Extract the marks marks(X)
# A Dtable containing two points Dmatrix <- matrix(c(0,1,1,0), nrow=2) PointType <- c("Type1", "Type2") PointWeight <- c(2,3) X <- Dtable(Dmatrix, PointType, PointWeight) # Extract the marks marks(X)
Simulates point patterns according to the null hypothesis and returns the envelope of m according to the confidence level.
mEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType, NeighborType = ReferenceType, CaseControl = FALSE, Original = TRUE, Approximate = ifelse(X$n < 10000, 0, 1), Adjust = 1, MaxRange = "ThirdW", SimulationType = "RandomLocation", Global = FALSE, verbose = interactive())
mEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType, NeighborType = ReferenceType, CaseControl = FALSE, Original = TRUE, Approximate = ifelse(X$n < 10000, 0, 1), Adjust = 1, MaxRange = "ThirdW", SimulationType = "RandomLocation", Global = FALSE, verbose = interactive())
X |
A point pattern ( |
r |
A vector of distances. If |
NumberOfSimulations |
The number of simulations to run, 100 by default. |
Alpha |
The risk level, 5% by default. |
ReferenceType |
One of the point types. |
NeighborType |
One of the point types, equal to the reference type by default to caculate univariate M. |
CaseControl |
Logical; if |
Original |
Logical; if |
Approximate |
if not 0 (1 is a good choice), exact distances between pairs of points are rounded to 1024 times |
Adjust |
Force the automatically selected bandwidth (following |
MaxRange |
The maximum value of |
SimulationType |
A string describing the null hypothesis to simulate. The null hypothesis may be "RandomLocation": points are redistributed on the actual locations (default); "RandomLabeling": randomizes point types, keeping locations and weights unchanged; "PopulationIndependence": keeps reference points unchanged, randomizes other point locations. |
Global |
Logical; if |
verbose |
Logical; if |
This envelope is local by default, that is to say it is computed separately at each distance. See Loosmore and Ford (2006) for a discussion.
The global envelope is calculated by iteration: the simulations reaching one of the upper or lower values at any distance are eliminated at each step. The process is repeated until Alpha / Number of simulations simulations are dropped. The remaining upper and lower bounds at all distances constitute the global envelope. Interpolation is used if the exact ratio cannot be reached.
An envelope object (envelope
). There are methods for print and plot for this class.
The fv
contains the observed value of the function, its average simulated value and the confidence envelope.
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106.
Kenkel, N. C. (1988). Pattern of Self-Thinning in Jack Pine: Testing the Random Mortality Hypothesis. Ecology 69(4): 1017-1024.
Lang G., Marcon E. and Puech F. (2014) Distance-Based Measures of Spatial Concentration: Introducing a Relative Density Function. HAL 01082178, 1-18.
Loosmore, N. B. and Ford, E. D. (2006). Statistical inference using the G or K point pattern spatial statistics. Ecology 87(8): 1925-1931.
Marcon, E. and F. Puech (2017). A typology of distance-based measures of spatial concentration. Regional Science and Urban Economics. 62:56-67.
Scholl, T. and Brenner, T. (2015) Optimizing distance-based methods for large data sets, Journal of Geographical Systems 17(4): 333-351.
Silverman, B. W. (1986). Density estimation for statistics and data analysis. Chapman and Hall, London.
data(paracou16) # Keep only 50% of points to run this example X <- as.wmppp(rthin(paracou16, 0.5)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate confidence envelope (should be 1000 simulations, reduced to 4 to save time) NumberOfSimulations <- 4 Alpha <- .10 autoplot(mEnvelope(X, , NumberOfSimulations, Alpha, "V. Americana", "Q. Rosea", Original = FALSE, SimulationType = "RandomLabeling"))
data(paracou16) # Keep only 50% of points to run this example X <- as.wmppp(rthin(paracou16, 0.5)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate confidence envelope (should be 1000 simulations, reduced to 4 to save time) NumberOfSimulations <- 4 Alpha <- .10 autoplot(mEnvelope(X, , NumberOfSimulations, Alpha, "V. Americana", "Q. Rosea", Original = FALSE, SimulationType = "RandomLabeling"))
Simulates point patterns according to the null hypothesis and returns the envelope of M according to the confidence level.
MEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType, NeighborType = ReferenceType, CaseControl = FALSE, SimulationType = "RandomLocation", Global = FALSE, verbose = interactive())
MEnvelope(X, r = NULL, NumberOfSimulations = 100, Alpha = 0.05, ReferenceType, NeighborType = ReferenceType, CaseControl = FALSE, SimulationType = "RandomLocation", Global = FALSE, verbose = interactive())
X |
A point pattern ( |
r |
A vector of distances. If |
NumberOfSimulations |
The number of simulations to run, 100 by default. |
Alpha |
The risk level, 5% by default. |
ReferenceType |
One of the point types. |
NeighborType |
One of the point types, equal to the reference type by default to caculate univariate M. |
CaseControl |
Logical; if |
SimulationType |
A string describing the null hypothesis to simulate. The null hypothesis may be "RandomLocation": points are redistributed on the actual locations (default); "RandomLabeling": randomizes point types, keeping locations and weights unchanged; "PopulationIndependence": keeps reference points unchanged, randomizes other point locations. |
Global |
Logical; if |
verbose |
Logical; if |
This envelope is local by default, that is to say it is computed separately at each distance. See Loosmore and Ford (2006) for a discussion.
The global envelope is calculated by iteration: the simulations reaching one of the upper or lower values at any distance are eliminated at each step. The process is repeated until Alpha / Number of simulations simulations are dropped. The remaining upper and lower bounds at all distances constitute the global envelope. Interpolation is used if the exact ratio cannot be reached.
An envelope object (envelope
). There are methods for print and plot for this class.
The fv
contains the observed value of the function, its average simulated value and the confidence envelope.
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106.
Kenkel, N. C. (1988). Pattern of Self-Thinning in Jack Pine: Testing the Random Mortality Hypothesis. Ecology 69(4): 1017-1024.
Loosmore, N. B. and Ford, E. D. (2006). Statistical inference using the G or K point pattern spatial statistics. Ecology 87(8): 1925-1931.
Marcon, E. and F. Puech (2017). A typology of distance-based measures of spatial concentration. Regional Science and Urban Economics. 62:56-67.
data(paracou16) # Keep only 50% of points to run this example X <- as.wmppp(rthin(paracou16, 0.5)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate confidence envelope (should be 1000 simulations, reduced to 4 to save time) NumberOfSimulations <- 4 Alpha <- .10 autoplot(MEnvelope(X, , NumberOfSimulations, Alpha, "V. Americana", "Q. Rosea", FALSE, "RandomLabeling"))
data(paracou16) # Keep only 50% of points to run this example X <- as.wmppp(rthin(paracou16, 0.5)) autoplot(X, labelSize = expression("Basal area (" ~cm^2~ ")"), labelColor = "Species") # Calculate confidence envelope (should be 1000 simulations, reduced to 4 to save time) NumberOfSimulations <- 4 Alpha <- .10 autoplot(MEnvelope(X, , NumberOfSimulations, Alpha, "V. Americana", "Q. Rosea", FALSE, "RandomLabeling"))
Estimates the m function
mhat(X, r = NULL, ReferenceType, NeighborType = ReferenceType, CaseControl = FALSE, Original = TRUE, Approximate = ifelse(X$n < 10000, 0, 1), Adjust = 1, MaxRange = "ThirdW", Individual = FALSE, CheckArguments = TRUE)
mhat(X, r = NULL, ReferenceType, NeighborType = ReferenceType, CaseControl = FALSE, Original = TRUE, Approximate = ifelse(X$n < 10000, 0, 1), Adjust = 1, MaxRange = "ThirdW", Individual = FALSE, CheckArguments = TRUE)
X |
A weighted, marked planar point pattern ( |
r |
A vector of distances. If |
ReferenceType |
One of the point types. |
NeighborType |
One of the point types. By default, the same as reference type. |
CaseControl |
Logical; if |
Original |
Logical; if |
Approximate |
if not 0 (1 is a good choice), exact distances between pairs of points are rounded to 1024 times |
Adjust |
Force the automatically selected bandwidth (following |
MaxRange |
The maximum value of |
Individual |
Logical; if |
CheckArguments |
Logical; if |
m is a weighted, density, relative measure of a point pattern structure (Lang et al., 2014). Its value at any distance is the ratio of neighbors of the NeighborType to all points around ReferenceType points, normalized by its value over the windows.
The number of neighbors at each distance is estimated by a Gaussian kernel whose bandwith is chosen optimally according to Silverman (1986: eq 3.31). It can be sharpened or smoothed by multiplying it by Adjust
. The bandwidth of Sheather and Jones (1991) would be better but it is very slow to calculate for large point patterns and it sometimes fails. It is often sharper than that of Silverman.
If X
is not a Dtable
object, the maximum value of r
is obtained from the geometry of the window rather than caculating the median distance between points as suggested by Duranton and Overman (2005) to save (a lot of) calculation time.
If CaseControl is TRUE
, then ReferenceType points are cases and NeighborType points are controls. The univariate concentration of cases is calculated as if NeighborType was equal to ReferenceType, but only controls are considered when counting all points around cases (Marcon et al., 2012). This makes sense when the sampling design is such that all points of ReferenceType (the cases) but only a sample of the other points (the controls) are recorded. Then, the whole distribution of points is better represented by the controls alone.
An object of class fv
, see fv.object
, which can be plotted directly using plot.fv
.
If Individual
is set to TRUE
, the object also contains the value of the function around each individual ReferenceType point taken as the only reference point. The column names of the fv
are "m_" followed by the point names, i.e. the row names of the marks of the point pattern.
Estimating m relies on calculating distances, exactly or approximately (if Approximate
is not 0).
Then distances are smoothed by estimating their probability density.
In contrast with Kdhat
, reflection is not used to estimate density close to the lowest distance.
The same kernel estimation is applied to the distances from reference points of neighbor points and of all points.
Since m is a relative function, a ratio of densities is calculated, that makes the features of the estimation vanish.
Density estimation heavily relies on the bandwith.
Starting from version 2.7, the optimal bandwith is computed from the distribution of distances between pairs of points up to twice the maximum distance considered.
The consequence is that choosing a smaller range of distances in argument r
results in less smoothed values.
The default values (
r = NULL
, MaxRange = "ThirdW"
) are such that almost all the pairs of points (except those more than 2/3 of the window diameter apart) are taken into account to determine the bandwith.
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106.
Lang G., Marcon E. and Puech F. (2014) Distance-Based Measures of Spatial Concentration: Introducing a Relative Density Function. HAL 01082178, 1-18.
Marcon, E., F. Puech and S. Traissac (2012). Characterizing the relative spatial structure of point patterns. International Journal of Ecology 2012(Article ID 619281): 11.
Scholl, T. and Brenner, T. (2015) Optimizing distance-based methods for large data sets, Journal of Geographical Systems 17(4): 333-351.
Sheather, S. J. and Jones, M. C. (1991) A reliable data-based bandwidth selection method for kernel density estimation. Journal of the Royal Statistical Society series B, 53, 683-690.
Silverman, B. W. (1986). Density estimation for statistics and data analysis. Chapman and Hall, London.
data(paracou16) autoplot(paracou16) # Calculate M autoplot(mhat(paracou16, , "V. Americana", "Q. Rosea"))
data(paracou16) autoplot(paracou16) # Calculate M autoplot(mhat(paracou16, , "V. Americana", "Q. Rosea"))
Estimates the M function
Mhat(X, r = NULL, ReferenceType, NeighborType = ReferenceType, CaseControl = FALSE, Individual = FALSE, CheckArguments = TRUE)
Mhat(X, r = NULL, ReferenceType, NeighborType = ReferenceType, CaseControl = FALSE, Individual = FALSE, CheckArguments = TRUE)
X |
A weighted, marked planar point pattern ( |
r |
A vector of distances. If |
ReferenceType |
One of the point types. |
NeighborType |
One of the point types. By default, the same as reference type. |
CaseControl |
Logical; if |
Individual |
Logical; if |
CheckArguments |
Logical; if |
M is a weighted, cumulative, relative measure of a point pattern structure. Its value at any distance is the ratio of neighbors of the NeighborType to all points around ReferenceType points, normalized by its value over the windows.
If CaseControl is TRUE
, then ReferenceType points are cases and NeighborType points are controls. The univariate concentration of cases is calculated as if NeighborType was equal to ReferenceType, but only controls are considered when counting all points around cases (Marcon et al., 2012). This makes sense when the sampling design is such that all points of ReferenceType (the cases) but only a sample of the other points (the controls) are recorded. Then, the whole distribution of points is better represented by the controls alone.
An object of class fv
, see fv.object
, which can be plotted directly using plot.fv
.
If Individual
is set to TRUE
, the object also contains the value of the function around each individual ReferenceType point taken as the only reference point. The column names of the fv
are "M_" followed by the point names, i.e. the row names of the marks of the point pattern.
Marcon, E. and Puech, F. (2010). Measures of the Geographic Concentration of Industries: Improving Distance-Based Methods. Journal of Economic Geography 10(5): 745-762.
Marcon, E., F. Puech and S. Traissac (2012). Characterizing the relative spatial structure of point patterns. International Journal of Ecology 2012(Article ID 619281): 11.
Marcon, E., and Puech, F. (2017). A Typology of Distance-Based Measures of Spatial Concentration. Regional Science and Urban Economics 62:56-67
data(paracou16) autoplot(paracou16) # Calculate M autoplot(Mhat(paracou16, , "V. Americana", "Q. Rosea"))
data(paracou16) autoplot(paracou16) # Calculate M autoplot(Mhat(paracou16, , "V. Americana", "Q. Rosea"))
This point pattern is from Paracou field station, French Guiana, managed by Cirad.
data(paracou16)
data(paracou16)
An object of class ppp.object
representing the point pattern of tree locations in a 250 x 300 meter sampling region. Each tree is marked with its species ("Q. Rosea", "V. Americana" or "Other"), and basal area (square centimeters).
Permanent data census of Paracou and Marcon et al. (2012).
Gourlet-Fleury, S., Guehl, J. M. and Laroussinie, O., Eds. (2004). Ecology & management of a neotropical rainforest. Lessons drawn from Paracou, a long-term experimental research site in French Guiana. Paris, Elsevier.
Marcon, E., F. Puech and S. Traissac (2012). Characterizing the relative spatial structure of point patterns. International Journal of Ecology 2012(Article ID 619281): 11.
data(paracou16) # Plot (second column of marks is Point Types) autoplot(paracou16, which.marks=2, leg.side="right")
data(paracou16) # Plot (second column of marks is Point Types) autoplot(paracou16, which.marks=2, leg.side="right")
Prints useful information of a confidence envelope of class "dbmssEnvelope"
## S3 method for class 'dbmssEnvelope' print(x, ...)
## S3 method for class 'dbmssEnvelope' print(x, ...)
x |
An object of class "dbmssEnvelope". |
... |
Ignored. |
"dbmssEnvelope" objects are similar to envelope
objects. The way they are printed is different to take into account the possibility of building global envelope following Duranton and Overman (2005): the global envelope is calculated by iteration: the simulations reaching one of the upper or lower values at any distance are eliminated at each step. The process is repeated until Alpha / Number of simulations simulations are dropped. The remaining upper and lower bounds at all distances constitute the global envelope. Interpolation is used if the exact ratio cannot be reached.
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106
data(paracou16) autoplot(paracou16) # Calculate intertype K envelope Envelope <- KEnvelope(paracou16, NumberOfSimulations = 20, Global = TRUE, ReferenceType = "V. Americana", NeighborType = "Q. Rosea") autoplot(Envelope) # print print(Envelope)
data(paracou16) autoplot(paracou16) # Calculate intertype K envelope Envelope <- KEnvelope(paracou16, NumberOfSimulations = 20, Global = TRUE, ReferenceType = "V. Americana", NeighborType = "Q. Rosea") autoplot(Envelope) # print print(Envelope)
Simulates of a point pattern according to the null hypothesis of population independence defined for K.
rPopulationIndependenceK(X, ReferenceType, NeighborType, CheckArguments = TRUE)
rPopulationIndependenceK(X, ReferenceType, NeighborType, CheckArguments = TRUE)
X |
A weighted, marked, planar point pattern ( |
ReferenceType |
One of the point types. |
NeighborType |
One of the point types. |
CheckArguments |
Logical; if |
Reference points are kept unchanged, neighbor type point positions are shifted by rshift
.
Other points are lost and point weights are not kept (they are set to 1) since the K function ignores them.
A new weighted, marked, planar point pattern (an object of class wmppp
, see wmppp.object
).
Goreaud, F. et Pelissier, R. (2003). Avoiding misinterpretation of biotic interactions with the intertype K12 fonction: population independence vs random labelling hypotheses. Journal of Vegetation Science 14(5): 681-692.
rPopulationIndependenceM
, rRandomLabeling
# Simulate a point pattern with three types X <- rpoispp(50) PointType <- sample(c("A", "B", "C"), X$n, replace=TRUE) PointWeight <- runif(X$n, min=1, max=10) marks(X) <- data.frame(PointType, PointWeight) X <- as.wmppp(X) # Plot the point pattern, using PointType as marks autoplot(X, main="Original pattern") # Randomize it Y <- rPopulationIndependenceK(X, "A", "B") # Points of type "A" are unchanged, points of type "B" have been moved altogether # Other points are lost and point weights are set to 1 autoplot(Y, main="Randomized pattern")
# Simulate a point pattern with three types X <- rpoispp(50) PointType <- sample(c("A", "B", "C"), X$n, replace=TRUE) PointWeight <- runif(X$n, min=1, max=10) marks(X) <- data.frame(PointType, PointWeight) X <- as.wmppp(X) # Plot the point pattern, using PointType as marks autoplot(X, main="Original pattern") # Randomize it Y <- rPopulationIndependenceK(X, "A", "B") # Points of type "A" are unchanged, points of type "B" have been moved altogether # Other points are lost and point weights are set to 1 autoplot(Y, main="Randomized pattern")
Simulates of a point pattern according to the null hypothesis of population independence defined for M
rPopulationIndependenceM(X, ReferenceType, CheckArguments = TRUE)
rPopulationIndependenceM(X, ReferenceType, CheckArguments = TRUE)
X |
A weighted, marked, planar point pattern ( |
ReferenceType |
One of the point types. |
CheckArguments |
Logical; if |
Reference points are kept unchanged, other points are redistributed randomly across locations.
A new weighted, marked, planar point pattern (an object of class wmppp
, see wmppp.object
).
Marcon, E. and Puech, F. (2010). Measures of the Geographic Concentration of Industries: Improving Distance-Based Methods. Journal of Economic Geography 10(5): 745-762.
Marcon, E., F. Puech and S. Traissac (2012). Characterizing the relative spatial structure of point patterns. International Journal of Ecology 2012(Article ID 619281): 11.
rPopulationIndependenceK
, rRandomLabelingM
# Simulate a point pattern with five types X <- rpoispp(50) PointType <- sample(c("A", "B", "C", "D", "E"), X$n, replace=TRUE) PointWeight <- runif(X$n, min=1, max=10) marks(X) <- data.frame(PointType, PointWeight) X <- as.wmppp(X) autoplot(X, main="Original pattern") # Randomize it Y <- rPopulationIndependenceM(X, "A") # Points of type "A" are unchanged, # all other points have been redistributed randomly across locations autoplot(Y, main="Randomized pattern")
# Simulate a point pattern with five types X <- rpoispp(50) PointType <- sample(c("A", "B", "C", "D", "E"), X$n, replace=TRUE) PointWeight <- runif(X$n, min=1, max=10) marks(X) <- data.frame(PointType, PointWeight) X <- as.wmppp(X) autoplot(X, main="Original pattern") # Randomize it Y <- rPopulationIndependenceM(X, "A") # Points of type "A" are unchanged, # all other points have been redistributed randomly across locations autoplot(Y, main="Randomized pattern")
Simulates of a point pattern according to the null hypothesis of random labeling.
rRandomLabeling(X, CheckArguments = TRUE)
rRandomLabeling(X, CheckArguments = TRUE)
X |
A weighted, marked, planar point pattern ( |
CheckArguments |
Logical; if |
Marks are redistributed randomly across the original point pattern.
A new weighted, marked, planar point pattern (an object of class wmppp
, see wmppp.object
).
Goreaud, F. et Pelissier, R. (2003). Avoiding misinterpretation of biotic interactions with the intertype K12 fonction: population independence vs random labelling hypotheses. Journal of Vegetation Science 14(5): 681-692.
rRandomLabelingM
, rPopulationIndependenceK
# Simulate a point pattern with five types X <- rpoispp(50) PointType <- sample(c("A", "B", "C", "D", "E"), X$n, replace=TRUE) PointWeight <- runif(X$n, min=1, max=10) marks(X) <- data.frame(PointType, PointWeight) X <- as.wmppp(X) autoplot(X, main="Original pattern") # Randomize it Y <- rRandomLabeling(X) # Types and weights have been redistributed randomly across locations autoplot(Y, main="Randomized pattern")
# Simulate a point pattern with five types X <- rpoispp(50) PointType <- sample(c("A", "B", "C", "D", "E"), X$n, replace=TRUE) PointWeight <- runif(X$n, min=1, max=10) marks(X) <- data.frame(PointType, PointWeight) X <- as.wmppp(X) autoplot(X, main="Original pattern") # Randomize it Y <- rRandomLabeling(X) # Types and weights have been redistributed randomly across locations autoplot(Y, main="Randomized pattern")
Simulates of a point pattern according to the null hypothesis of random labelling defined for M
rRandomLabelingM(X, CheckArguments = TRUE)
rRandomLabelingM(X, CheckArguments = TRUE)
X |
A weighted, marked, planar point pattern ( |
CheckArguments |
Logical; if |
Point types are randomized. Locations and weights are kept unchanged. If both types and weights must be randomized together (Duranton and Overman, 2005; Marcon and Puech, 2010), use rRandomLocation
.
A new weighted, marked, planar point pattern (an object of class wmppp
, see wmppp.object
).
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106.
Marcon, E. and Puech, F. (2010). Measures of the Geographic Concentration of Industries: Improving Distance-Based Methods. Journal of Economic Geography 10(5): 745-762.
Marcon, E., F. Puech and S. Traissac (2012). Characterizing the relative spatial structure of point patterns. International Journal of Ecology 2012(Article ID 619281): 11.
rRandomLabeling
, rPopulationIndependenceM
# Simulate a point pattern with five types X <- rpoispp(50) PointType <- sample(c("A", "B", "C", "D", "E"), X$n, replace=TRUE) PointWeight <- runif(X$n, min=1, max=10) marks(X) <- data.frame(PointType, PointWeight) X <- as.wmppp(X) autoplot(X, main="Original pattern") # Randomize it Y <- rRandomLabelingM(X) # Labels have been redistributed randomly across locations # But weights are unchanged autoplot(Y, main="Randomized pattern")
# Simulate a point pattern with five types X <- rpoispp(50) PointType <- sample(c("A", "B", "C", "D", "E"), X$n, replace=TRUE) PointWeight <- runif(X$n, min=1, max=10) marks(X) <- data.frame(PointType, PointWeight) X <- as.wmppp(X) autoplot(X, main="Original pattern") # Randomize it Y <- rRandomLabelingM(X) # Labels have been redistributed randomly across locations # But weights are unchanged autoplot(Y, main="Randomized pattern")
Simulates of a point pattern according to the null hypothesis of random location.
rRandomLocation(X, ReferenceType = "", CheckArguments = TRUE)
rRandomLocation(X, ReferenceType = "", CheckArguments = TRUE)
X |
A weighted, marked, planar point pattern ( |
ReferenceType |
One of the point types. |
CheckArguments |
Logical; if |
Points are redistributed randomly across the locations of the original point pattern. This randomization is equivalent to random labeling, considering the label is both point type and point weight.
If ReferenceType
is specified, then only reference type points are kept in the orginal point pattern before randomization.
A new weighted, marked, planar point pattern (an object of class wmppp
, see wmppp.object
).
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106.
Marcon, E. and Puech, F. (2010). Measures of the Geographic Concentration of Industries: Improving Distance-Based Methods. Journal of Economic Geography 10(5): 745-762.
# Simulate a point pattern with five types X <- rpoispp(50) PointType <- sample(c("A", "B", "C", "D", "E"), X$n, replace=TRUE) PointWeight <- runif(X$n, min=1, max=10) marks(X) <- data.frame(PointType, PointWeight) X <- as.wmppp(X) autoplot(X, main="Original pattern") # Randomize it Y <- rRandomLocation(X) # Points have been redistributed randomly across locations autoplot(Y, main="Randomized pattern")
# Simulate a point pattern with five types X <- rpoispp(50) PointType <- sample(c("A", "B", "C", "D", "E"), X$n, replace=TRUE) PointWeight <- runif(X$n, min=1, max=10) marks(X) <- data.frame(PointType, PointWeight) X <- as.wmppp(X) autoplot(X, main="Original pattern") # Randomize it Y <- rRandomLocation(X) # Points have been redistributed randomly across locations autoplot(Y, main="Randomized pattern")
Simulations of a point pattern according to the null hypothesis of random position defined for K.
rRandomPositionK(X, Precision = 0, CheckArguments = TRUE)
rRandomPositionK(X, Precision = 0, CheckArguments = TRUE)
X |
A weighted, marked, planar point pattern ( |
Precision |
Accuracy of point coordinates, measured as a part of distance unit. See notes. Default is 0 for no approximation. |
CheckArguments |
Logical; if |
Points marks are kept unchanged and their position is drawn in a binomial process by runifpoint
.
A new weighted, marked, planar point pattern (an object of class wmppp
, see wmppp.object
).
Simulations in a binomial process keeps the same number of points, so that marks can be redistributed. If a real CSR simulation is needed and marks are useless, use rpoispp
.
Actual data coordinates are often rounded. Use the Precision
argument to simulate point patterns with the same rounding procedure. For example, if point coordinates are in meters and rounded to the nearest half meter, use Precision = 0.5
so that the same approximation is applied to the simulated point patterns.
# Simulate a point pattern with two types X <- rpoispp(5) PointType <- sample(c("A", "B"), X$n, replace=TRUE) PointWeight <- runif(X$n, min=1, max=10) marks(X) <- data.frame(PointType, PointWeight) X <- as.wmppp(X) autoplot(X, main="Original pattern") # Randomize it Y <- rRandomPositionK(X) # Points are randomly distributed autoplot(Y, main="Randomized pattern")
# Simulate a point pattern with two types X <- rpoispp(5) PointType <- sample(c("A", "B"), X$n, replace=TRUE) PointWeight <- runif(X$n, min=1, max=10) marks(X) <- data.frame(PointType, PointWeight) X <- as.wmppp(X) autoplot(X, main="Original pattern") # Randomize it Y <- rRandomPositionK(X) # Points are randomly distributed autoplot(Y, main="Randomized pattern")
Performs spatial smoothing of the individual values of distance-based measures computed in the neighborhood of each point (Marcon and Puech, 2023).
## S3 method for class 'wmppp' Smooth(X, fvind, distance = NULL, Quantiles = FALSE, sigma = bw.scott(X, isotropic = TRUE), Weighted = TRUE, Adjust = 1, Nbx = 128, Nby = 128, ..., CheckArguments = TRUE)
## S3 method for class 'wmppp' Smooth(X, fvind, distance = NULL, Quantiles = FALSE, sigma = bw.scott(X, isotropic = TRUE), Weighted = TRUE, Adjust = 1, Nbx = 128, Nby = 128, ..., CheckArguments = TRUE)
X |
A point pattern ( |
fvind |
An object of class |
distance |
The distance at which the function value must be considered. The default value is the median distance used to calculate the function values. |
Quantiles |
If |
Weighted |
If |
sigma |
The bandwidth used for smoothing.
A Gaussian kernel is used (see |
Adjust |
Force the selected bandwidth ( |
Nbx , Nby
|
The number of columns and rows (pixels) of the resulting map, 128 by default. Increase it for quality, paid by increasing computing time. |
... |
Extra arguments, passed to |
CheckArguments |
If |
An image that can be plotted.
If quantiles have been computed in fvind
, attributes "High" and "Low" contain logical vectors to indentify significantly high and low quantiles.
Marcon, E. and Puech, F. (2023). Mapping distributions in non-homogeneous space with distance-based methods. Journal of Spatial Econometrics 4(1), 13.
ReferenceType <- "V. Americana" NeighborType <- "Q. Rosea" # Calculate individual intertype M(distance) values fvind <- Mhat(paracou16, r=c(0, 30), ReferenceType, NeighborType, Individual=TRUE) # Plot the point pattern with values of M(30 meters) p16_map <- Smooth(paracou16, fvind, distance=30) 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)
ReferenceType <- "V. Americana" NeighborType <- "Q. Rosea" # Calculate individual intertype M(distance) values fvind <- Mhat(paracou16, r=c(0, 30), ReferenceType, NeighborType, Individual=TRUE) # Plot the point pattern with values of M(30 meters) p16_map <- Smooth(paracou16, fvind, distance=30) 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)
spatstat methods for a ppp.object
applied to a wmppp.object
.
## S3 method for class 'wmppp' sharpen(X, ...) ## S3 method for class 'wmppp' superimpose(...) ## S3 method for class 'wmppp' unique(x, ...) ## S3 method for class 'wmppp' i[j, drop=FALSE, ..., clip=FALSE]
## S3 method for class 'wmppp' sharpen(X, ...) ## S3 method for class 'wmppp' superimpose(...) ## S3 method for class 'wmppp' unique(x, ...) ## S3 method for class 'wmppp' i[j, drop=FALSE, ..., clip=FALSE]
X , x
|
A two-dimensional point pattern. An object of class "wmppp". |
... |
Arguments passed to the |
i |
Subset index. Either a valid subset index in the usual R sense, indicating which points should be retained, or a window (an object of class "owin") delineating a subset of the original observation window, or a pixel image with logical values defining a subset of the original observation window. |
j |
Redundant. Included for backward compatibility. |
drop |
Logical value indicating whether to remove unused levels of the marks, if the marks are a factor. |
clip |
Logical value indicating how to form the window of the resulting point pattern, when |
spatstat methods for ppp
objects returning a ppp
object can be applied to a wmppp
and return a wpppp
with these methods which just call the ppp.object
method and change the class of the result for convenience.
Some spatstat functions such as rthin
are not generic so they always return a ppp.object
when applied to a wmppp.object
. Their result may be converted by as.wmppp
.
An object of class "wmppp"
.
sharpen.ppp
, superimpose.ppp
, unique.ppp
Prints a useful summary of a confidence envelope of class "dbmssEnvelope"
## S3 method for class 'dbmssEnvelope' summary(object, ...)
## S3 method for class 'dbmssEnvelope' summary(object, ...)
object |
An object of class "dbmssEnvelope". |
... |
Ignored. |
"dbmssEnvelope" objects are similar to envelope
objects. Their summary is different to take into account the possibility of building global envelope following Duranton and Overman (2005): the global envelope is calculated by iteration: the simulations reaching one of the upper or lower values at any distance are eliminated at each step. The process is repeated until Alpha / Number of simulations simulations are dropped. The remaining upper and lower bounds at all distances constitute the global envelope. Interpolation is used if the exact ratio cannot be reached.
Duranton, G. and Overman, H. G. (2005). Testing for Localisation Using Micro-Geographic Data. Review of Economic Studies 72(4): 1077-1106
data(paracou16) autoplot(paracou16) # Calculate intertype K envelope Envelope <- KEnvelope(paracou16, NumberOfSimulations = 20, Global = TRUE, ReferenceType = "V. Americana", NeighborType = "Q. Rosea") autoplot(Envelope) summary(Envelope)
data(paracou16) autoplot(paracou16) # Calculate intertype K envelope Envelope <- KEnvelope(paracou16, NumberOfSimulations = 20, Global = TRUE, ReferenceType = "V. Americana", NeighborType = "Q. Rosea") autoplot(Envelope) summary(Envelope)
Creates an object of class "wmppp"
representing a two-dimensional point pattern with weights and labels.
wmppp(df, window = NULL, unitname = NULL)
wmppp(df, window = NULL, unitname = NULL)
df |
A dataframe with at least two columns containing point coordinates. |
window |
An object of calls "owin" ( |
unitname |
Name of unit of length. Either a single character string, or a vector of two character strings giving the singular and plural forms, respectively. Ignored if |
Columns named "X", "Y", "PointType", "PointWeight" (capitalization is ignored) are searched to build the "wmppp"
object and set the point coordinates, type and weight. If they are not found, columns are used in this order. If columns are missing, PointType
is set to "All" and PointWeight
to 1.
If a "PointName" column is found, it is used to set the row names of the marks, else the original row names are used.
If the window is not specified, a rectangle containing all points is used, and unitname
is used.
An object of class "wmppp"
.
# Draw the coordinates of 10 points X <- runif(10) Y <- runif(10) # Draw the point types. PointType <- sample(c("A", "B"), 10, replace=TRUE) # Plot the point pattern. Weights are set to 1 ant the window is adjusted. plot(wmppp(data.frame(X, Y, PointType)), , which.marks=2)
# Draw the coordinates of 10 points X <- runif(10) Y <- runif(10) # Draw the point types. PointType <- sample(c("A", "B"), 10, replace=TRUE) # Plot the point pattern. Weights are set to 1 ant the window is adjusted. plot(wmppp(data.frame(X, Y, PointType)), , which.marks=2)
A class "wmppp"
to represent a two-dimensional point pattern of class ppp
whose marks are a dataframe with two columns:
PointType
: labels, as factors
PointWeight
: weights.
This class represents a two-dimensional point pattern dataset. wmppp
objects are also of class ppp
.
Objects of class wmppp
may be created by the function wmppp
and converted from other types of data by the function as.wmppp
.
ppp.object
,
wmppp
,
as.wmppp
autoplot.wmppp
# Draw the coordinates of 10 points X <- runif(10) Y <- runif(10) # Draw the point types and weights PointType <- sample(c("A", "B"), 10, replace=TRUE) PointWeight <- runif(10) # Build the point pattern X <- wmppp(data.frame(X, Y, PointType, PointWeight), owin()) # Plot the point pattern. which.marks=1 for point weights, 2 for point types par(mfrow=c(1,2)) plot(X, which.marks=1, main="Point weights") plot(X, which.marks=2, main="Point types") # Or use autoplot for a ggplot autoplot(X)
# Draw the coordinates of 10 points X <- runif(10) Y <- runif(10) # Draw the point types and weights PointType <- sample(c("A", "B"), 10, replace=TRUE) PointWeight <- runif(10) # Build the point pattern X <- wmppp(data.frame(X, Y, PointType, PointWeight), owin()) # Plot the point pattern. which.marks=1 for point weights, 2 for point types par(mfrow=c(1,2)) plot(X, which.marks=1, main="Point weights") plot(X, which.marks=2, main="Point types") # Or use autoplot for a ggplot autoplot(X)