Title: | Extension to 'spatstat' for Local Composite Likelihood |
---|---|
Description: | Extension to the 'spatstat' package, enabling the user to fit point process models to point pattern data by local composite likelihood ('geographically weighted regression'). |
Authors: | Adrian Baddeley [aut, cre] |
Maintainer: | Adrian Baddeley <[email protected]> |
License: | GPL (>= 2) |
Version: | 5.1-0 |
Built: | 2024-09-14 05:38:01 UTC |
Source: | https://github.com/baddstats/spatstat.local |
Extension of the spatstat package, for fitting spatial point process models by local composite likelihood.
The main functions are
locppm |
Local likelihood fit of Poisson model |
Local pseudolikelihood fit of Gibbs model | |
locmincon |
Local minimum contrast fit |
of Neyman-Scott or Cox model | |
loccit |
Local composite likelihood fit |
of Neyman-Scott or Cox model |
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
Uses cross-validation to select a smoothing bandwidth for locally fitting a Cox or cluster point process model.
bw.loccit(..., use.fft=TRUE, srange = NULL, ns = 9, sigma = NULL, fftopt=list(), verbose = TRUE)
bw.loccit(..., use.fft=TRUE, srange = NULL, ns = 9, sigma = NULL, fftopt=list(), verbose = TRUE)
... |
Arguments passed to |
use.fft |
Logical value indicating whether to use a quick-and-dirty approximation based on a first order Taylor expansion. |
srange |
Range of values of the smoothing parameter |
ns |
Number of values of the smoothing parameter |
sigma |
Vector of values of the smoothing parameter to be searched. |
fftopt |
Developer use only. |
verbose |
Logical value indicating whether to display progress reports. |
This function determines the optimal value of the smoothing
parameter sigma
to be used in a call to loccit
.
The function loccit
fits
a Cox or cluster point process model
to point pattern data by local composite likelihood.
The degree of local smoothing is controlled by a smoothing parameter
sigma
which is an argument to loccit
.
For each value of sigma
in a search interval,
the function bw.loccit
fits the model locally
and evaluates a cross-validation criterion. The optimal value of
sigma
is returned.
A numerical value giving the selected bandwidth.
The result also belongs to the class "bw.optim"
which can be plotted.
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
X <- redwood[owin(c(0,1), c(-1,-1/2))] Ns <- if(interactive()) 16 else 2 b <- bw.loccit(X, ~1, "Thomas", srange=c(0.07, 0.14), ns=Ns) b plot(b)
X <- redwood[owin(c(0,1), c(-1,-1/2))] Ns <- if(interactive()) 16 else 2 b <- bw.loccit(X, ~1, "Thomas", srange=c(0.07, 0.14), ns=Ns) b plot(b)
Uses cross-validation to select a smoothing bandwidth for locally fitting a Poisson or Gibbs point process model.
bw.locppm(..., method = c("fft", "exact", "taylor"), srange = NULL, ns = 9, sigma = NULL, additive = TRUE, verbose = TRUE)
bw.locppm(..., method = c("fft", "exact", "taylor"), srange = NULL, ns = 9, sigma = NULL, additive = TRUE, verbose = TRUE)
... |
Arguments passed to |
method |
Method of calculation. The default |
srange |
Range of values of the smoothing parameter |
ns |
Number of values of the smoothing parameter |
sigma |
Vector of values of the smoothing parameter to be searched.
Overrides the values of |
additive |
Logical value indicating whether to calculate the leverage
approximation on the scale of the intensity ( |
verbose |
Logical value indicating whether to display progress reports. |
This function determines the optimal value of the smoothing
parameter sigma
to be used in a call to locppm
.
The function locppm
fits
a Poisson or Gibbs point process model
to point pattern data by local composite likelihood.
The degree of local smoothing is controlled by a smoothing parameter
sigma
which is an argument to locppm
.
This function bw.locppm
determines the optimal value of
sigma
by cross-validation.
For each value of sigma
in a search interval,
the function bw.locppm
fits the model locally
with smoothing bandwidth sigma
,
and evaluates the composite likelihood cross-validation criterion
LCV(sigma)
defined in Baddeley (2016), section 3.2.
The value of sigma
which maximises LCV(sigma)
is returned.
A numerical value giving the selected bandwidth.
The result also belongs to the class "bw.optim"
which can be plotted.
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
Ns <- if(interactive()) 16 else 2 b <- bw.locppm(swedishpines, ~1, srange=c(2.5,4.5), ns=Ns) b plot(b)
Ns <- if(interactive()) 16 else 2 b <- bw.locppm(swedishpines, ~1, srange=c(2.5,4.5), ns=Ns) b plot(b)
Conducts a Monte Carlo test of homogeneity for a locally-fitted Poisson or Gibbs point process model.
homtest(X, ..., nsim = 19, test = c("residuals", "score", "taylor", "likelihood"), locations = c("coarse", "fine", "split"), ladjust = NULL, use.fft = NULL, simul = NULL, verbose = TRUE, Xname = NULL)
homtest(X, ..., nsim = 19, test = c("residuals", "score", "taylor", "likelihood"), locations = c("coarse", "fine", "split"), ladjust = NULL, use.fft = NULL, simul = NULL, verbose = TRUE, Xname = NULL)
X |
A point pattern (object of class |
... |
Additional arguments passed to |
nsim |
Number of simulations for the Monte Carlo test. |
test |
The local test statistic to be used:
either |
locations , use.fft
|
Arguments passed to |
ladjust |
Optional argument passed to |
simul |
Optional information that determines
how to simulate the realisations from the null hypothesis.
An expression in the R language (that will be evaluated
|
verbose |
Logical value indicating whether to print progress reports. |
Xname |
Optional character string name for the dataset |
This function performs a Monte Carlo test of the null hypothesis of homogeneity (i.e.\ constant parameter values) for the locally-fitted Poisson point process or Gibbs point process specified by the arguments.
The type of test is controlled by the argument test
.
test="likelihood"
:
the locally fitted model is computed as locppm(X, ...)
.
The local composite likelihood ratio test statistic of this model
is computed at each location,
and the mean of this statistic over the window is computed.
test="taylor"
:
the locally fitted model is computed as locppm(X, ...)
.
The Taylor approximation to the
local composite likelihood ratio test statistic of this model
is computed at each location,
and the mean of this statistic over the window is computed.
test="score"
:
the locally fitted model is computed as locppm(X, ...)
.
The local score test statistic of this model is computed at each location,
and the mean of this statistic over the window is computed.
method="residuals"
:
the homogeneous model is fitted as ppm(X, ...)
.
The smoothed score residuals of this model are computed at each
location, and the mean of the squared norm over the window
is computed.
The test statistic is computed for the data pattern X
and for each of nsim
simulated realisations from the
homogeneous model. The Monte Carlo -value is computed.
An object of class "htest"
containing the test outcome.
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
To compute the test statistic only, see
homtestmap
.
## Not run: homtest(swedishpines) ## End(Not run)
## Not run: homtest(swedishpines) ## End(Not run)
Compute the test statistic for the test of homogeneity of a locally-fitted Poisson or Gibbs point process model.
homteststat(object, ..., verbose = FALSE) homtestmap(object, ..., what=c("components", "statistic", "pvalue"), test = c("score", "taylor", "likelihood"), ladjust=c("none", "moment", "PSS"), calibrate=c("chisq", "Satterthwaite", "firstmoment"), simple = !is.null(theta0), theta0 = NULL, poolmoments=NULL, sigma = NULL, saveall = FALSE, use.fft = TRUE, verbose = TRUE) ## S3 method for class 'homtestmap' update(object, ..., what=NULL, test=NULL, ladjust=NULL, calibrate=NULL, saveall=FALSE, poolmoments=NULL)
homteststat(object, ..., verbose = FALSE) homtestmap(object, ..., what=c("components", "statistic", "pvalue"), test = c("score", "taylor", "likelihood"), ladjust=c("none", "moment", "PSS"), calibrate=c("chisq", "Satterthwaite", "firstmoment"), simple = !is.null(theta0), theta0 = NULL, poolmoments=NULL, sigma = NULL, saveall = FALSE, use.fft = TRUE, verbose = TRUE) ## S3 method for class 'homtestmap' update(object, ..., what=NULL, test=NULL, ladjust=NULL, calibrate=NULL, saveall=FALSE, poolmoments=NULL)
object |
Locally-fitted point process (object of class |
... |
For |
what |
Character string (partially matched)
indicating whether to return the vector components
of the local test statistic, or the value of the local test statistic, or
the local |
test |
Character string (partially matched)
indicating whether to perform
the local score test ( |
ladjust |
Character string (partially matched) specifying an adjustment to the composite likelihood ratio test statistic. |
calibrate |
Character string (partially matched)
specifying how to calculate |
simple |
Logical value indicating whether to treat the fitted model
as a simple null hypothesis ( |
theta0 |
Coefficient vector specifying a simple null hypothesis. |
poolmoments |
Logical value indicating how to calculate the reference distribution
for the likelihood ratio test statistic (and thus how to
calculate |
sigma |
Smoothing bandwidth. |
saveall |
Logical value indicating whether to compute a complete set of sufficient statistics and save them as an attribute of the result. See Details. |
use.fft |
For software testing purposes only. Logical value indicating whether to use data computed by the Fast Fourier Transform. |
verbose |
Logical value indicating whether to print progress reports. |
These functions are used by homtest
to
perform a Monte Carlo test of the null hypothesis of
homogeneity (i.e.\ constant parameter values) for the locally-fitted
Poisson point process or Gibbs point process object
.
The function homtestmap
computes
either the local likelihood ratio test statistic
or the local score test statistic.
If what="statistic"
, then the result is a scalar-valued
function giving the local values of the test statistic.
If what="pvalue"
, the result is a scalar-valued function
giving the local
-value at each location
.
If
what="components"
, the result is a vector-valued
function containing the components of the quadratic form;
the squared norm of
is
equal to the desired test statistic at each location
.
If saveall=TRUE
, then a complete set of sufficient statistics is
calculated and stored as an attribute of the result. This makes it
possible to compute all of the statistics and values
described above.
The function update.homtestmap
, a method for the
generic function update
, converts
an object of class "homtestmap"
from one of these formats to
another, where possible. Except in trivial cases, this requires that
the "homtestmap"
object was computed with saveall=TRUE
.
The function homteststat
computes the mean of
the local test statistic or the mean
of the local -values over the
observation window.
To compute the -values when
test="likelihood"
or test="taylor"
, the values of the local likelihood ratio
test statistic are referred to a gamma distribution whose first two
moments are estimated from the data. If poolmoments=FALSE
,
the local estimates of the moments are used; if
poolmoments=TRUE
, the spatial average of these estimates
is used. The default is to use pooling whenever it is
theoretically justified, namely when the template
model is a stationary point process.
Finer control over the computation is possible
using the arguments ...
passed to locppm
.
For homteststat
, a numeric value giving the test statistic.
For homtestmap
and update.homtestmap
,
a spatially-sampled function object (class "ssf"
; see
ssf
).
This object also belongs to the special class
"homtestmap"
which has a print method.
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
example(locppm) plot(H <- homtestmap(fit)) H
example(locppm) plot(H <- homtestmap(fit)) H
Fits a Neyman-Scott cluster process or Cox point process model using a locally-weighted composite likelihood.
loccit(X, trend = ~1, clusters = c("Thomas", "MatClust", "Cauchy", "VarGamma", "LGCP"), covariates = NULL, ..., diagnostics = FALSE, taylor = FALSE, sigma = NULL, f = 1/4, clustargs = list(), control = list(), rmax, covfunargs=NULL, use.gam=FALSE, nd=NULL, eps=NULL, niter=3, fftopt = list(), verbose = TRUE)
loccit(X, trend = ~1, clusters = c("Thomas", "MatClust", "Cauchy", "VarGamma", "LGCP"), covariates = NULL, ..., diagnostics = FALSE, taylor = FALSE, sigma = NULL, f = 1/4, clustargs = list(), control = list(), rmax, covfunargs=NULL, use.gam=FALSE, nd=NULL, eps=NULL, niter=3, fftopt = list(), verbose = TRUE)
X |
Point pattern. |
trend |
Formula (without a left hand side) specifying the form of the logarithm of the intensity. |
clusters |
Character string determining the cluster model. Partially matched. |
covariates |
The values of any spatial covariates (other than the Cartesian coordinates) required by the model. A named list of pixel images, functions, windows or numeric constants. |
diagnostics |
Whether to perform auxiliary calculations in addition to the local estimates of the model parameters. |
... |
Additional arguments passed to
|
taylor |
Logical value indicating whether to fit the model
exactly at each spatial location ( |
sigma |
Standard deviation of Gaussian kernel for local likelihood. |
f |
Argument passed to |
clustargs |
List of additional parameters for the cluster model,
passed to the function |
control |
List of control arguments passed to the generic optimisation
function |
rmax |
Maximum distance between pairs of points that will contribute to the composite likelihood. |
covfunargs , use.gam , nd , eps
|
Arguments passed to |
niter |
Number of iterations in algorithm if |
fftopt |
Developer use only. |
verbose |
Logical. If |
This function fits a Cox or cluster process model to point pattern data locally, using the local Palm likelihood technique (Baddeley, 2016, section 8).
It can be used in the same way as kppm
and effectively performs local fitting of the same model.
An object of class "loccit"
.
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
X <- redwood[owin(c(0,1), c(-1,-1/2))] fit <- loccit(X, ~1, "Thomas", nd=5, control=list(maxit=20)) fit
X <- redwood[owin(c(0,1), c(-1,-1/2))] fit <- loccit(X, ~1, "Thomas", nd=5, control=list(maxit=20)) fit
Fits a Neyman-Scott cluster process or Cox point process model using local minimum contrast.
locmincon(..., sigma = NULL, f = 1/4, verbose = TRUE, localstatargs = list(), LocalStats = NULL, tau = NULL)
locmincon(..., sigma = NULL, f = 1/4, verbose = TRUE, localstatargs = list(), LocalStats = NULL, tau = NULL)
... |
Arguments passed to |
sigma |
Standard deviation of Gaussian kernel for local likelihood. |
f |
Argument passed to |
verbose |
Logical. If |
localstatargs |
Optional. List of arguments to be passed to the local statistic
|
LocalStats |
Optional. Values of the local statistics, if they have already been computed. |
tau |
Optional. Bandwidth for smoothing the fitted cluster parameters. |
The template or homogeneous model is first fitted by
kppm
.
The statistic used to fit the template model is determined
(as explained in the help for kppm
)
by the arguments statistic
and trend
.
The local version of this statistic is then computed.
If statistic="K"
and trend=~1
for example, the template model is fitted
using the function
Kest
,
and the local version is the local function
localK
. The possibilities are:
statistic |
stationary? | template | local |
"K" |
yes | Kest
|
localK
|
"K" |
no | Kinhom
|
localKinhom
|
"pcf" |
yes | pcf
|
localpcf
|
"pcf" |
no | pcfinhom
|
localpcfinhom
|
These local functions, one for each data point, are then spatially
averaged, using a Gaussian kernel with standard deviation sigma
.
Finally the model is fitted to each of the averaged local functions
to obtain a local fit at each data point.
Object of class "locmincon"
.
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
X <- redwood[owin(c(0,1), c(-1,-1/2))] fit <- locmincon(X, ~1, "Thomas", sigma=0.07) fit
X <- redwood[owin(c(0,1), c(-1,-1/2))] fit <- locmincon(X, ~1, "Thomas", sigma=0.07) fit
Fits Poisson or Gibbs point process model using local likelihood or pseudolikelihood.
locppm(..., sigma = NULL, f = 1/4, vcalc = c("none", "t", "hessian", "hom", "lik", "full"), locations=c("split", "fine", "coarse"), ngrid = NULL, grideps = NULL, verbose = TRUE, use.fft=FALSE, fft.algorithm="closepairs")
locppm(..., sigma = NULL, f = 1/4, vcalc = c("none", "t", "hessian", "hom", "lik", "full"), locations=c("split", "fine", "coarse"), ngrid = NULL, grideps = NULL, verbose = TRUE, use.fft=FALSE, fft.algorithm="closepairs")
... |
Arguments passed to |
sigma |
Standard deviation of Gaussian kernel for local likelihood. |
f |
Argument passed to |
vcalc |
Type of variance calculation to be performed. See Details. |
locations |
Spatial locations for local calculations. See Details. |
ngrid |
Dimensions of coarse grid, if used. See Details.
Incompatible with |
grideps |
Grid spacing of coarse grid, if used. See Details.
Incompatible with |
verbose |
Logical. If |
use.fft |
Logical value indicating whether to perform
computations using the Fast Fourier Transform.
With |
fft.algorithm |
Developer use only. |
This function fits a Poisson or Gibbs point process model to point pattern data by local likelihood or local pseudolikelihood respectively.
This command should be used in the same way as
ppm
.
The point pattern data and the specification of the model
are given in the leading arguments ...
which are passed
directly to ppm
.
In all cases, the local estimates of the coefficients are
computed. However, because the variance calculations are
time-consuming, the default is not to perform them.
This is controlled by the argument vcalc
.
vcalc = "none"
:no variance calculations are performed.
vcalc = "t"
:the statistic for each parameter is computed
for the local model.
vcalc = "hessian"
:the local Hessian matrix is computed, and its negative inverse is used as a surrogate for the local variance.
vcalc = "hom"
:No local fitting is performed. Calculations are performed only for the homogeneous (template) model. The variance of the local parameter estimates under the homogeneous model is computed.
vcalc = "lik"
:In addition to the calculations for vcalc="hom"
described
above, if use.fft=FALSE
the algorithm also computes the local composite likelihood
ratio test statistic for the test of homogeneity.
If use.fft=TRUE
then vcalc="lik"
is equivalent to
vcalc="hom"
.
vcalc = "full"
:all variance calculations are performed for the local model.
The spatial locations, where the model fits and variance calculations
are performed, are determined by the argument locations
.
locations = "fine"
:The calculations are performed at every quadrature point of the model. This can take a very long time.
locations = "coarse"
:The calculations are performed at the points of a coarse grid
with dimensions specified by ngrid
or grideps
.
locations = "split"
:The fitted coefficients are computed at every quadrature point
of the model, but the variance calculations (if any) are
performed at a coarse grid of locations,
specified by ngrid
or grideps
.
If neither ngrid
nor grideps
is specified,
the default is ngrid=10
.
If use.fft=FALSE
(the default), all desired quantities are
computed exactly, by an iterative algorithm that
fits a separate model at each spatial location. This can be quite
slow.
If use.fft=TRUE
, we only compute quantities that can be
obtained using the Fast Fourier Transform, resulting in much faster
calculations (sometimes 3 orders of magnitude faster) when
locations="fine"
.
Properties of the homogeneous model are
computed accurately. Properties of the locally-fitted model are
approximated by a first order Taylor expansion.
An object of class "locppm"
representing the fitted model.
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
fit <- locppm(swedishpines, ~1, sigma=9, nd=20) fit
fit <- locppm(swedishpines, ~1, sigma=9, nd=20) fit
Methods for various generic functions, for the class
"locmincon"
of locally fitted cluster or Cox point process models.
## S3 method for class 'locmincon' as.ppp(X, ...) ## S3 method for class 'locmincon' print(x, ...)
## S3 method for class 'locmincon' as.ppp(X, ...) ## S3 method for class 'locmincon' print(x, ...)
x , X
|
A locally-fitted Cox or cluster point process model (object of class
|
... |
Additional arguments |
Objects of class "locmincon"
represent locally fitted
cluster or Cox point process models.
The functions documented here provided methods for this class,
for the generic functions
as.ppp
and
print
.
as.ppp
returns an object of class "ppp"
.
print
returns NULL
.
Adrian Baddeley
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
example(locmincon) fit as.ppp(fit)
example(locmincon) fit as.ppp(fit)
Methods for various generic functions, for the class
"locppm"
of locally fitted Gibbs point process models.
## S3 method for class 'locppm' as.interact(object) ## S3 method for class 'locppm' as.ppm(object) ## S3 method for class 'locppm' coef(object, ..., which = c("local", "homogeneous")) ## S3 method for class 'locppm' confint(object, parm, level = 0.95, ..., which = c("local", "homogeneous")) ## S3 method for class 'locppm' is.poisson(x) ## S3 method for class 'locppm' print(x, ...)
## S3 method for class 'locppm' as.interact(object) ## S3 method for class 'locppm' as.ppm(object) ## S3 method for class 'locppm' coef(object, ..., which = c("local", "homogeneous")) ## S3 method for class 'locppm' confint(object, parm, level = 0.95, ..., which = c("local", "homogeneous")) ## S3 method for class 'locppm' is.poisson(x) ## S3 method for class 'locppm' print(x, ...)
object , x
|
A locally-fitted Gibbs point process model (object of class
|
... |
Additional arguments passed to the default method
(for |
which |
Character string determining whether to perform calculations
for the local Gibbs model ( |
parm |
The parameter or parameters for which a confidence interval is
desired. A character string or character vector matching the names
of |
level |
Confidence level: a number between 0 and 1. |
Objects of class "locppm"
represent locally fitted Gibbs
point process models.
The functions documented here provided methods for this class,
for the generic functions
as.interact
,
as.ppm
,
coef
,
confint
,
is.poisson
and
print
.
For the coef
and confint
methods, the calculations
can be performed either on the locally fitted model or
on its homogeneous equivalent, by changing the argument which
.
as.interact
returns an interaction structure (object of class
"interact"
).
as.ppm
returns a fitted Gibbs model (object of class
"ppm"
).
coef
and confint
return a numeric vector if which="homogeneous"
and an object of class "ssf"
if which="local"
.
is.poisson
returns a logical value.
print
returns NULL
.
Adrian Baddeley
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
fit <- locppm(swedishpines, ~1, sigma=9, nd=20, vcalc="full", locations="coarse") fit is.poisson(fit) coef(fit) coef(fit, which="homogeneous") confint(fit) confint(fit, which="homogeneous") as.ppm(fit) as.interact(fit)
fit <- locppm(swedishpines, ~1, sigma=9, nd=20, vcalc="full", locations="coarse") fit is.poisson(fit) coef(fit) coef(fit, which="homogeneous") confint(fit) confint(fit, which="homogeneous") as.ppm(fit) as.interact(fit)
Plot an object of class "loccit"
representing a locally-fitted cluster or Cox point process model.
## S3 method for class 'loccit' plot(x, ..., what = c("modelpar", "coefs", "lambda"), how = c("smoothed", "exact"), which = NULL, pre=NULL, post=NULL)
## S3 method for class 'loccit' plot(x, ..., what = c("modelpar", "coefs", "lambda"), how = c("smoothed", "exact"), which = NULL, pre=NULL, post=NULL)
x |
The model to be plotted.
A locally-fitted cluster or Cox point process model (object of class
|
... |
Arguments passed to |
what |
Character string determining which quantities to display:
|
how |
Character string determining whether to display the
fitted parameter values at the data points ( |
which |
Optional. Which component(s) of the vector-valued quantity to display. An index or index vector. Default is to plot all components. |
pre , post
|
Transformations to apply before and after smoothing. |
This is a method for the generic command plot
for the class "loccit"
.
The argument which
, if present, specifies
which fitted parameters are displayed. It may be any kind of
index for a numeric vector.
The quantities are computed at irregularly-placed points.
If how="exact"
the exact computed values
will be displayed as circles centred at the locations where they
were computed. If how="smoothed"
these
values will be kernel-smoothed using Smooth.ppp
and displayed as a pixel image.
NULL
.
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
X <- redwood[owin(c(0,1), c(-1,-1/2))] fitc <- loccit(X, ~1, "Thomas", nd=5, control=list(maxit=20)) plot(fitc, how="exact") plot(fitc, how="smoothed")
X <- redwood[owin(c(0,1), c(-1,-1/2))] fitc <- loccit(X, ~1, "Thomas", nd=5, control=list(maxit=20)) plot(fitc, how="exact") plot(fitc, how="smoothed")
Plot an object of class "locmincon"
representing a locally-fitted cluster or Cox point process model.
## S3 method for class 'locmincon' plot(x, ..., how = c("exact", "smoothed"), which = NULL, sigma = NULL, do.points = TRUE)
## S3 method for class 'locmincon' plot(x, ..., how = c("exact", "smoothed"), which = NULL, sigma = NULL, do.points = TRUE)
x |
The model to be plotted.
A locally-fitted cluster or Cox point process model (object of class
|
... |
Arguments passed to |
how |
Character string determining whether to display the
fitted parameter values at the data points ( |
which |
Optional. Which component(s) of the vector-valued quantity to display. An index or index vector. Default is to plot all components. |
sigma |
Numeric. Smoothing bandwidth to be used if |
do.points |
Logical. Whether to display the original point data as well. |
This is a method for the generic command plot
for the class "locmincon"
.
The argument which
, if present, specifies
which fitted parameters are displayed. It may be any kind of
index for a numeric vector.
The quantities are computed at irregularly-placed points.
If how="exact"
the exact computed values
will be displayed as circles centred at the locations where they
were computed. If how="smoothed"
these
values will be kernel-smoothed using Smooth.ppp
and displayed as a pixel image.
NULL
.
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
locmincon
,
methods.locmincon
,
plot
, plot.default
X <- redwood[owin(c(0,1), c(-1,-1/2))] fitm <- locmincon(X, ~1, "Thomas", sigma=0.07) plot(fitm, how="smoothed") plot(fitm, how="exact")
X <- redwood[owin(c(0,1), c(-1,-1/2))] fitm <- locmincon(X, ~1, "Thomas", sigma=0.07) plot(fitm, how="smoothed") plot(fitm, how="exact")
Plot an object of class "locppm"
representing a locally-fitted Poisson or Gibbs point process model.
## S3 method for class 'locppm' plot(x, ..., what = "cg", which = NULL) ## S3 method for class 'locppm' contour(x, ..., what = "cg", which = NULL)
## S3 method for class 'locppm' plot(x, ..., what = "cg", which = NULL) ## S3 method for class 'locppm' contour(x, ..., what = "cg", which = NULL)
x |
A locally-fitted Poisson or Gibbs point process model (object of class
|
... |
Arguments passed to |
what |
What quantity to display. A character string. The default is to display the fitted coefficient vectors. |
which |
Which component(s) of the vector-valued quantity to display. An index or index vector. |
These are methods for the generic commands plot
and contour
, for the class "locppm"
.
The argument what
specifies what quantity will be displayed:
"cg" |
Fitted coefficients of local model |
"vg" |
Local variance matrix for Gibbs model |
"vh" |
Local variance matrix for homogeneous model |
"tg" |
-statistics based on "coefs" and "vg"
|
Typically these quantities are vector-valued (matrices are converted
to vectors). The argument which
, if present, specifies
which elements of the vector are displayed. It may be any kind of
index for a numeric vector.
The plotting is performed by plot.ssf
.
NULL
.
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
locppm
,
methods.locppm
,
plot
, plot.default
fit <- locppm(swedishpines, ~1, sigma=9, nd=20, vcalc="hessian", locations="coarse") plot(fit) plot(fit, what="Vg")
fit <- locppm(swedishpines, ~1, sigma=9, nd=20, vcalc="hessian", locations="coarse") plot(fit) plot(fit, what="Vg")
Computes the fitted intensity of a locally-fitted Cox process or cluster process model.
## S3 method for class 'loccit' predict(object, ...) ## S3 method for class 'loccit' fitted(object, ..., new.coef=NULL)
## S3 method for class 'loccit' predict(object, ...) ## S3 method for class 'loccit' fitted(object, ..., new.coef=NULL)
object |
Locally fitted point process model (object of class |
... |
Arguments passed to |
new.coef |
New values for the fitted coefficients. A matrix in which each row gives the fitted coefficients at one of the quadrature points of the model. |
The fitted intensity is computed.
An object of class "ssf"
as described in ssf
.
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
X <- redwood[owin(c(0,1), c(-1,-1/2))] fit <- loccit(X, ~1, "Thomas", nd=5, control=list(maxit=20)) lam <- predict(fit)
X <- redwood[owin(c(0,1), c(-1,-1/2))] fit <- loccit(X, ~1, "Thomas", nd=5, control=list(maxit=20)) lam <- predict(fit)
Computes the fitted intensity of a locally-fitted Poisson point process model, or the fitted intensity, trend or conditional intensity of a locally-fitted Gibbs point process model.
## S3 method for class 'locppm' fitted(object, ..., type = c("cif", "trend", "intensity"), new.coef=NULL) ## S3 method for class 'locppm' predict(object, ..., type = c("cif", "trend", "intensity"), locations=NULL, new.coef=NULL)
## S3 method for class 'locppm' fitted(object, ..., type = c("cif", "trend", "intensity"), new.coef=NULL) ## S3 method for class 'locppm' predict(object, ..., type = c("cif", "trend", "intensity"), locations=NULL, new.coef=NULL)
object |
A locally-fitted Poisson or Gibbs point process model (object of class
|
... |
Currently ignored. |
new.coef |
New vector or matrix of values for the model coefficients. |
locations |
Point pattern of locations where prediction should be computed. |
type |
Character string (partially matched) specifying the type of
predicted value: the conditional intensity |
These are methods for the generic functions
fitted
and
predict
for the class "locppm"
of locally-fitted Gibbs point process
models.
The fitted
method computes,
for each quadrature point v
(or in general, at each point v
where a local model was fitted),
the intensity of the locally-fitted model at v
.
The result is a numeric vector.
The predict
computes the fitted intensity at any specified
set of locations
, and returns the result as an ssf
object.
For fitted.locppm
, a numeric vector.
For predict.locppm
, an object of class "ssf"
as described in ssf
.
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
fit <- locppm(cells, sigma=0.1, use.fft=TRUE) lam <- predict(fit)
fit <- locppm(cells, sigma=0.1, use.fft=TRUE) lam <- predict(fit)
Computes the sibling probability of a locally fitted cluster point process model.
## S3 method for class 'loccit' psib(object) ## S3 method for class 'locmincon' psib(object)
## S3 method for class 'loccit' psib(object) ## S3 method for class 'locmincon' psib(object)
object |
Fitted cluster point process model
(object of class |
In a Poisson cluster process, two points are called siblings
if they belong to the same cluster, that is, if they had the same
parent point. If two points of the process are
separated by a distance , the probability that
they are siblings is
where
is the
pair correlation function of the process.
The value is the probability that,
if two points of the process are situated very close to each other,
they came from the same cluster. This probability
is an index of the strength of clustering, with high values
suggesting strong clustering.
This concept was proposed in Baddeley, Rubak and Turner (2015, page 479) and Baddeley (2016).
The function psib
is generic, with methods for
"kppm"
, "loccit"
and "locmincon"
.
The functions described here are the methods for
locally-fitted cluster models of class "loccit"
and "locmincon"
.
They compute the spatially-varying sibling probability of the
locally-fitted model.
A spatially sampled function (object of class
"ssf"
) giving the spatially-varying sibling probability.
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
## Not run: fit <- loccit(redwood, ~1, "Thomas") ## End(Not run) fit plot(psib(fit))
## Not run: fit <- loccit(redwood, ~1, "Thomas") ## End(Not run) fit plot(psib(fit))
Applies kernel smoothing to the fitted cluster parameters of a locally-fitted cluster or Cox point process model.
## S3 method for class 'locmincon' Smooth(X, tau = NULL, ...)
## S3 method for class 'locmincon' Smooth(X, tau = NULL, ...)
X |
Object of class |
tau |
Smoothing bandwidth. |
... |
Additional arguments passed to |
An object of class "locmincon"
represents
a locally-fitted Cox or cluster point process model.
It provides estimates of the cluster parameters at each of the
data points of the original point pattern dataset.
The parameter estimates will be smoothed using a Gaussian
kernel with standard deviation tau
.
A pixel image or a list of pixel images.
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
fit <- locmincon(redwood) Smooth(fit, tau=0.1)
fit <- locmincon(redwood) Smooth(fit, tau=0.1)
Applies kernel smoothing to one of the components of a locally-fitted Gibbs point process model.
## S3 method for class 'locppm' Smooth(X, ..., what = "cg")
## S3 method for class 'locppm' Smooth(X, ..., what = "cg")
X |
A locally-fitted Gibbs point process model (object of class
|
... |
Arguments passed to |
what |
Component to be smoothed. A character string. The default is to smooth the fitted coefficient vectors. |
This function extracts the selected quantity from the fitted object
and spatially smooths it using Smooth.ppp
.
The result is a pixel image or a list of pixel images.
A pixel image or a list of pixel images.
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
fit <- locppm(cells, sigma=0.1, use.fft=TRUE) plot(Smooth(fit))
fit <- locppm(cells, sigma=0.1, use.fft=TRUE) plot(Smooth(fit))
Perform a local -test for the presence of a covariate effect
in a locally fitted Poisson or Gibbs point process model.
ttestmap(object, term, ..., method = c("exact", "hessian", "taylor"), grid = FALSE, ngrid = NULL, grideps = NULL, verbose = TRUE)
ttestmap(object, term, ..., method = c("exact", "hessian", "taylor"), grid = FALSE, ngrid = NULL, grideps = NULL, verbose = TRUE)
object |
Locally fitted Poisson or Gibbs point process model
(object of class |
term |
Term to be dropped from the model. A character string matching a term in the model formula |
... |
Ignored. |
method |
Choice of method to be used to evaluate the |
grid |
Logical. If |
ngrid |
Number of grid points (in each axis direction)
for the coarse grid. Incompatible with |
grideps |
Spacing (horizontal and vertical) between grid points
for the coarse grid. Incompatible with |
verbose |
Logical value indicating whether to print progress reports. |
The argument object
should be a locally-fitted
Poisson or Gibbs point process model (object of class
"locppm"
created by locppm
).
This function computes the local test statistic
for the test that a particular covariate effect in the model is zero.
This is described in Baddeley (2016, sections 3 and 5).
Object of class "ssf"
.
Adrian Baddeley [email protected].
Baddeley, A. (2017) Local composite likelihood for spatial point patterns. Spatial Statistics 22, 261–295. DOI: 10.1016/j.spasta.2017.03.001
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.
fit <- with(copper, locppm(Points, ~D, covariates=list(D=distfun(Lines)), nd=c(7,15))) plot(ttestmap(fit, "D"))
fit <- with(copper, locppm(Points, ~D, covariates=list(D=distfun(Lines)), nd=c(7,15))) plot(ttestmap(fit, "D"))
Given a locally-fitted Cox or cluster point process model, evaluate an expression involving the fitted cluster parameters.
## S3 method for class 'locmincon' with(data, ...) ## S3 method for class 'loccit' with(data, ...)
## S3 method for class 'locmincon' with(data, ...) ## S3 method for class 'loccit' with(data, ...)
data |
An object of class |
... |
Arguments passed to |
These are method for the generic function with
for
the classes "locmincon"
and "loccit"
.
An object of class "locmincon"
or "loccit"
represents
a locally-fitted Cox or cluster point process model.
It contains a data frame
which provides estimates of the cluster parameters at each of the
data points of the original point pattern dataset.
The expression specified by ...
will be evaluated
in this dataframe. If the result of evaluation
is a data frame with one row for each data point,
or a numeric vector with one entry for each data point,
then the result will be an object of class "ssf"
containing this information. Otherwise, the result will be
a numeric vector.
An object of class "ssf"
or a numeric vector.
Adrian Baddeley [email protected].
example(locmincon) with(fit, kappa * sigma2) example(locmincon) with(fit, kappa * sigma2)
example(locmincon) with(fit, kappa * sigma2) example(locmincon) with(fit, kappa * sigma2)