Learn R Programming

spatstat.explore (version 3.3-1)

SpatialQuantile.ppp: Spatially Weighted Quantile of Values at Points

Description

Given a spatial point pattern with numeric marks, compute a weighted quantile of the mark values, with spatially-varying weights that depend on distance to the data points.

Usage

# S3 method for ppp
SpatialQuantile(X, prob = 0.5, sigma = NULL, ...,
        type = 1, at = c("pixels", "points"), leaveoneout = TRUE,
        weights = NULL, edge = TRUE, diggle = FALSE, verbose = FALSE)

Value

If X has a single column of marks:

  • If at="pixels" (the default), the result is a pixel image (object of class "im").

  • If at="points", the result is a numeric vector of length equal to the number of points in X.

If X has a data frame of marks:

  • If at="pixels" (the default), the result is a named list of pixel images (object of class "im"). There is one image for each column of marks. This list also belongs to the class "solist", for which there is a plot method.

  • If at="points", the result is a data frame with one row for each point of X, and one column for each column of marks. Entries are values of the interpolated function at the points of X.

The return value has attributes

"sigma" and "varcov" which report the smoothing bandwidth that was used.

Arguments

X

A spatial point pattern (object of class "ppp") with numeric marks.

prob

Probability for which the quantile is required. A single numeric value between 0 and 1.

sigma

Smoothing bandwidth, passed to density.ppp.

...

Further arguments passed to density.ppp controlling the spatial smoothing.

type

Integer specifying the type of median (using the convention of quantile.default; see Details). Only types 1 and 4 are currently implemented.

at

Character string indicating whether to compute the quantile at every pixel of a pixel image (at="pixels", the default) or at every data point of X (at="points").

leaveoneout

Logical value indicating whether to compute a leave-one-out estimator. Applicable only when at="points".

weights

Optional vector of numeric weights attached to the points of X.

edge,diggle

Arguments passed to density.ppp to determine the edge correction.

verbose

Logical value specifying whether to print progress reports during the calculation.

Author

Adrian Baddeley Adrian.Baddeley@curtin.edu.au.

Details

The argument X should be a spatial point pattern (object of class "ppp") with numeric marks.

The algorithm computes the weighted quantile of the mark values at each desired spatial location, using spatially-varying weights which depend on distance to the data points.

Suppose the data points are at spatial locations \(x_1,\ldots,x_n\) and have mark values \(y_1,\ldots,y_n\). For a query location \(u\), the smoothed quantile is defined as the weighted quantile of the mark values \(y_1,\ldots,y_n\) with weights \(w_1(u),\ldots,w_n(u)\), where $$ w_i(u) = \frac{k(u,x_i)}{\sum_{j=1}^n k(u,x_j)} $$ where \(k(u,v)\) is the smoothing kernel with bandwidth sigma.

If at="points" and leaveoneout=TRUE, then a leave-one-out calculation is performed, which means that when the query location is a data point \(x_i\), the value at the data point is ignored, and the weighted quantile is computed from the values \(y_j\) for all \(j\) not equal to \(i\).

The calculation of the quantile value depends on the argument type which is interpreted in the same way as for quantile.default. Currently, only types 1 and 4 are implemented. If type=1 (the default), the quantile value is one of the mark values (one of the values in marks(x)). If type=4, the quantile value is obtained by linearly interpolating between mark values. Note that the default values of type in SpatialQuantile.ppp and SpatialMedian.ppp are different.

See Also

SpatialMedian.ppp, SpatialMedian.

Examples

Run this code
   X <- longleaf
   if(!interactive()) {
    ## mark values rounded to nearest multiple of 10 to reduce check time
    marks(X) <- round(marks(X), -1)
   }
   Z <- SpatialQuantile(X, prob=0.25, sigma=30)
   ZX <- SpatialQuantile(X, prob=0.25, sigma=30, at="points")

Run the code above in your browser using DataLab