Package 'stpp'

Title: Space-Time Point Pattern Simulation, Visualisation and Analysis
Description: Many of the models encountered in applications of point process methods to the study of spatio-temporal phenomena are covered in 'stpp'. This package provides statistical tools for analyzing the global and local second-order properties of spatio-temporal point processes, including estimators of the space-time inhomogeneous K-function and pair correlation function. It also includes tools to get static and dynamic display of spatio-temporal point patterns. See Gabriel et al (2013) <doi:10.18637/jss.v053.i02>.
Authors: Edith Gabriel [aut, cre], Peter J Diggle [aut], Barry Rowlingson [aut], Francisco J Rodriguez-Cortes [aut]
Maintainer: Edith Gabriel <[email protected]>
License: GPL-3
Version: 2.0-8
Built: 2024-11-26 06:28:33 UTC
Source: CRAN

Help Index


Space-time data animation

Description

Provide an animation of spatio-temporal point patterns.

Usage

animation(xyt, s.region, t.region, runtime=1, incident="red", 
prevalent="pink3", pch=19, cex=0.5, plot.s.region=TRUE, 
scales=TRUE, border.frac=0.05, add=FALSE)

Arguments

xyt

Data-matrix containing the (x,y,t)(x,y,t)-coordinates.

s.region

Two-column matrix specifying polygonal region containing all data-locations xyt[,1:2]. If missing, s.region is the bounding box of xyt[,1:2].

t.region

Interval containing all data-times xyt[,3]. If missing, t.region is defined by the range of xyt[,3].

runtime

Approximate running time of animation, in seconds, but it is longer than expected. Can also be NULL.

incident

Colour in which incident point xyt[i,1:2] is plotted at time xyt[i,3].

prevalent

Colour to which prevalent point xyt[i,1:2] fades at time xyt[i+1,3].

pch

Plotting symbol used for each point.

cex

Magnification of plotting symbol relative to standard size.

plot.s.region

If TRUE, plot s.region as polygon.

scales

If TRUE, plot X and Y axes with scales.

border.frac

Extent of border of plotting region surounding s.region, as fraction of ranges of X and Y.

add

If TRUE, add the animation to an existing plot.

Value

None

Author(s)

Peter J Diggle, Edith Gabriel <[email protected]>.


Create data in spatio-temporal point format

Description

Create data in spatio-temporal point format.

Usage

as.3dpoints(...)

Arguments

...

Any object(s), such as xx, yy and tt vectors of the same length, or a list or data frame containing xx, yy and tt vectors. Valid options for ... are: a points object: returns it unaltered; a list with xx, yy and tt elements of the same length: returns a points object with the xx, yy and tt elements as the coordinates of the points; three vectors of equal length: returns a points object with the first vector as the xx coordinates, the second vector as the yy-coordinates and the third vector as the tt-coordinates.

Value

The output is an object of the class stpp. as.3dpoints tries to return the argument(s) as a spatio-temporal points object.

Author(s)

Edith Gabriel <[email protected]>, Peter Diggle, Barry Rowlingson.


Anisotropic Space-Time Inhomogeneous KK-function

Description

Compute an estimation of the Anisotropic Space-Time inhomogeneous KK-function.

Usage

ASTIKhat(xyt, s.region, t.region, lambda, dist, times, ang,
  correction = "border")

Arguments

xyt

Coordinates and times (x,y,t)(x,y,t) of the point pattern.

s.region

Two-column matrix specifying polygonal region containing all data locations. If s.region is missing, the bounding box of xyt[,1:2] is considered.

t.region

Vector containing the minimum and maximum values of the time interval. If t.region is missing, the range of xyt[,3] is considered.

dist

Vector of distances uu at which K^ϕ(r,t)\widehat{K}_{\phi}(r,t) is computed. If missing, the maximum of dist is given by min(Sx,Sy)/4\min(S_x,S_y)/4, where SxS_x and SyS_y represent the maximum width and height of the bounding box of s.region.

times

Vector of times vv at which K^ϕ(r,t)\widehat{K}_{\phi}(r,t) is computed. If missing, the maximum of times is given by (TmaxTmin)/4(T_{\max} - T_{\min})/4, where TminT_{\min} and TmaxT_{\max} are the minimum and maximum of the time interval TT.

lambda

Vector of values of the space-time intensity function evaluated at the points (x,y,t)(x,y,t) in S×TS\times T. If lambda is missing, the estimate of the anisotropic space-time KK-function is computed as for the homogeneous case, i.e. considering n/S×Tn/|S\times T| as an estimate of the space-time intensity.

ang

Angle in radians at which K^ϕ(r,t)\widehat{K}_{\phi}(r,t) is computed. The argument ang=2*pi by default.

correction

A character vector specifying the edge correction(s) to be applied among "border", "modified.border", "translate" and "none" (see STIKhat). The default is "border".

Value

A list containing:

AKhat

ndist x ntimes matrix containing values of K^ϕ(u,t)\widehat{K}_{\phi}(u,t).

dist, times

Parameters passed in argument.

correction

The name(s) of the edge correction method(s) passed in argument.

Author(s)

Francisco J. Rodriguez-Cortes <[email protected]>

References

Illian, J. B., Penttinen, A., Stoyan, H. and Stoyan, D. (2008). Statistical Analysis and Modelling of Spatial Point Patterns. John Wiley and Sons, London.

Gonzalez, J. A., Rodriguez-Cortes, F. J., Cronie, O., Mateu, J. (2016). Spatio-temporal point process statistics: a review. Spatial Statistics. Accepted.

Ohser, J. and D. Stoyan (1981). On the second-order and orientation analysis of planar stationary point processes. Biometrical Journal 23, 523-533.


2001 food-and-mouth epidemic, north Cumbria (UK)

Description

This data set gives the spatial locations and reported times of food-and-mouth disease in north Cumbria (UK), 2001. It is of no scientific value, as it deliberately excludes confidential information on farms at risk in the study-region. It is included in the package purely as an illustrative example.

Usage

data(fmd)

Format

A matrix containing (x,y,t)(x,y,t) coordinates of the 648 observations.

References

Diggle, P., Rowlingson, B. and Su, T. (2005). Point process methodology for on-line spatio-temporal disease surveillance. Environmetrics, 16, 423–34.

See Also

northcumbria for boundaries of the county of north Cumbria.


Spatial mark variogram function

Description

Computes an estimator of the spatial mark variogram function.

Usage

gsp(xyt,s.region,s.lambda,ds,ks="epanech",hs,correction="none",approach="simplified")

Arguments

xyt

Spatial coordinates and times (x,y,t)(x,y,t) of the point pattern.

s.region

Two-column matrix specifying polygonal region containing all data locations.

s.lambda

Vector of values of the spatial intensity function evaluated at the points (x,y)(x,y) in WW. If s.lambda is missing, the estimate of the spatial mark correlation function is computed as for the homogeneous case, i.e. considering n/Wn/|W| as an estimate of the spatial intensity under the parameter approach="standardised".

ds

A vector of distances u at which gsp(u) is computed.

ks

A kernel function for the spatial distances. The default is the "epanech" kernel. It can also be "box" for the uniform kernel, or "biweight".

hs

A bandwidth of the kernel function ks.

correction

A character vector specifying the edge-correction(s) to be applied among "isotropic", "border", "modified.border", "translate", "setcovf" and "none". The default is "none".

approach

A character vector specifying the approach to use for the estimation to be applied among "simplified" or "standardised". If approach is missing, "simplified" is considered by default.

Details

By default, this command calculates an estimate of the spatial mark variogram function γ[sp](r)\gamma_[sp](r) for a spatio-temporal point pattern.

Value

egsp

A vector containing the values of γsp(r)\gamma_{sp}(r) estimated

ds

If ds is missing, a vector of distances u at which gsp(u) is computed from 0 to until quarter of the maximum distance between the points in the pattern.

kernel

A vector of names and bandwidth of the spatial kernel.

gsptheo

Value under the Poisson case is calculated considering τ\tau=max(xyt[,3])-min(xyt[,3]).

Author(s)

Francisco J. Rodriguez Cortes <[email protected]> https://fjrodriguezcortes.wordpress.com

References

Baddeley, A., Rubak, E., Turner, R. (2015). Spatial Point Patterns: Methodology and Applications with R. CRC Press, Boca Raton.

Chiu, S. N., Stoyan, D., Kendall, W. S., and Mecke, J. (2013). Stochastic Geometry and its Applications. John Wiley & Sons.

Gabriel, E., Rowlingson, B., Diggle P J. (2013) stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software. 53, 1-29.

Illian, J B., Penttinen, A., Stoyan, H. and Stoyan, D. (2008). Statistical Analysis and Modelling of Spatial Point Patterns. John Wiley and Sons, London.

Stoyan, D., Rodriguez-Cortes, F. J., Mateu, J., and Gille, W. (2017). Mark variograms for spatio-temporal point processes. Spatial Statistics. 20, 125-147.

Examples

## Not run:
#################

# A realisation of spatio-temporal homogeneous Poisson point processes
hpp <- rpp(lambda = 100, replace = FALSE)$xyt

# R plot
plot(hpp)

# This function provides an kernel estimator of the spatial mark variogram function
out <- gsp(hpp)

# R plot - Spatial mark variogram function
par(mfrow=c(1,1))
xl <- c(0,0.25)
yl <- c(0,max(out$gsptheo,out$egsp))
plot(out$ds,out$egsp,type="l",xlab="r = distance",ylab=expression(gamma[sp](r)),
                 xlim=xl,ylim=yl,col=1,cex.lab=1.5,cex.axis=1.5)
lines(out$ds,rep(out$gsptheo,length(out$ds)),col=11)

## End(Not run)

Temporal mark variogram function

Description

Computes an estimator of the temporal mark variogram function.

Usage

gte(xyt,t.region,t.lambda,dt,kt="epanech",ht,correction="none",approach="simplified")

Arguments

xyt

Spatial coordinates and times (x,y,t)(x,y,t) of the point pattern.

t.region

Vector containing the minimum and maximum values of the time interval.

t.lambda

Vector of values of the temporal intensity function evaluated at the points tt in TT. If t.lambda is missing, the estimate of the temporal mark correlation function is computed as for the homogeneous case, i.e. considering n/Tn/|T| as an estimate of the temporal intensity under the parameter approach="standardised".

dt

A vector of times v at which gte(v) is computed.

kt

A kernel function for the temporal distances. The default is the "epanech" kernel. It can also be "box" for the uniform kernel, or "biweight".

ht

A bandwidth of the kernel function kt.

correction

A character vector specifying the edge-correction(s) to be applied among "isotropic", "border", "modified.border", "translate", "setcovf" and "none". The default is "none".

approach

A character vector specifying the approach to use for the estimation to be applied among "simplified" or "standardised". If approach is missing, "simplified" is considered by default.

Details

By default, this command calculates an estimate of the temporal mark variogram function γ[te](t)\gamma_[te](t) for a spatio-temporal point pattern.

Value

egte

A vector containing the values of γ[te](v)\gamma_[te](v) estimated.

dt

Parameter passed in argument. If dt is missing, a vector of temporal distances v at which gte(v) is computed from 0 to until quarter of the maximum distance between the times in the temporal pattern.

kernel

Parameters passed in argument. A vector of names and bandwidth of the spatial kernel.

gtetheo

Value under the Poisson case is calculated considering the side lengths of the bounding box of xyt[,1:2].

Author(s)

Francisco J. Rodriguez Cortes <[email protected]> https://fjrodriguezcortes.wordpress.com

References

Baddeley, A., Rubak, E., Turner, R. (2015). Spatial Point Patterns: Methodology and Applications with R. CRC Press, Boca Raton.

Chiu, S. N., Stoyan, D., Kendall, W. S., and Mecke, J. (2013). Stochastic Geometry and its Applications. John Wiley & Sons.

Gabriel, E., Rowlingson, B., Diggle P J. (2013) stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software 53, 1-29.

Illian, J B., Penttinen, A., Stoyan, H. and Stoyan, D. (2008). Statistical Analysis and Modelling of Spatial Point Patterns. John Wiley and Sons, London.

Stoyan, D., Rodriguez-Cortes, F. J., Mateu, J., and Gille, W. (2017). Mark variograms for spatio-temporal point processes. Spatial Statistics. 20, 125-147.

Examples

## Not run:
#################

# A realisation of spatio-temporal homogeneous Poisson point processes
hpp <- rpp(lambda = 100, replace = FALSE)$xyt

# R plot
plot(hpp)

# This function provides an kernel estimator of the temporal mark variograma function
out <- gte(hpp)

# R plot - Temporal mark variogram function
par(mfrow=c(1,1))
xl <- c(0,0.25)
yl <- c(0,max(out$egte,out$gtetheo))
plot(out$dt,out$egte,type="l",xlab="t = time",ylab=expression(gamma[te](t)),
                 xlim=xl,ylim=yl,col=1,cex.lab=1.5,cex.axis=1.5)
lines(out$dt,rep(out$gtetheo,length(out$dt)),col=11)

## End(Not run)

Spatio-temporal point objects

Description

Tests for data in spatio-temporal point format.

Usage

is.3dpoints(x)

Arguments

x

any object.

Value

is.3dpoints returns TRUE if x is a spatio-temporal points object, FALSE otherwise.

Author(s)

Edith Gabriel <[email protected]>, Peter Diggle, Barry Rowlingson.


Estimation of the Space-Time Inhomogeneous K LISTA functions

Description

Compute an estimate of the space-time K LISTA functions.

Usage

KLISTAhat(xyt, s.region, t.region, dist, times, lambda, correction = "isotropic")

Arguments

xyt

Coordinates and times (x,y,t)(x,y,t) of the point pattern.

s.region

Two-column matrix specifying polygonal region containing all data locations. If s.region is missing, the bounding box of xyt[,1:2] is considered.

t.region

Vector containing the minimum and maximum values of the time interval. If t.region is missing, the range of xyt[,3] is considered.

dist

Vector of distances uu at which K(i)(u,v)K^{(i)}(u,v) is computed. If missing, the maximum of dist is given by min(Sx,Sy)/4\min(S_x,S_y)/4, where SxS_x and SyS_y represent the maximum width and height of the bounding box of s.region.

times

Vector of times vv at which K(i)(u,v)K^{(i)}(u,v) is computed. If missing, the maximum of times is given by (TmaxTmin)/4(T_{\max} - T_{\min})/4, where TminT_{\min} and TmaxT_{\max} are the minimum and maximum of the time interval TT.

lambda

Vector of values of the space-time intensity function evaluated at the points (x,y,t)(x,y,t) in S×TS\times T. If lambda is missing, the estimate of the space-time pair correlation function is computed as for the homogeneous case, i.e. considering (n1)/S×T(n-1)/|S \times T| as an estimate of the space-time intensity.

correction

A character vector specifying the edge correction(s) to be applied among "isotropic", "border", "modified.border", "translate" and "none" (see PCFhat). The default is "isotropic".

Details

An individual product density LISTA functions K(i)(.,.)K^{(i)}(.,.) should reveal the extent of the contribution of the event (ui,ti)(u_i,t_i) to the global estimator of the K-function K(.,.)K(.,.), and may provide a further description of structure in the data (e.g., determining events with similar local structure through dissimilarity measures of the individual LISTA functions), for more details see Siino et al. (2019).

Value

A list containing:

list.KLISTA

A list containing the values of the estimation of K(i)(r,t)K^{(i)}(r,t) for each one of nn points of the point pattern by matrixs.

klistatheo

ndist x ntimes matrix containing theoretical values for a Poisson process.

dist, times

Parameters passed in argument.

correction

The name(s) of the edge correction method(s) passed in argument.

Author(s)

Francisco J. Rodriguez-Cortes <[email protected]>

References

Baddeley, A. and Turner, J. (2005). spatstat: An R Package for Analyzing Spatial Point Pattens. Journal of Statistical Software 12, 1-42.

Cressie, N. and Collins, L. B. (2001). Analysis of spatial point patterns using bundles of product density LISA functions. Journal of Agricultural, Biological, and Environmental Statistics 6, 118-135.

Cressie, N. and Collins, L. B. (2001). Patterns in spatial point locations: Local indicators of spatial association in a minefield with clutter Naval Research Logistics (NRL), John Wiley & Sons, Inc. 48, 333-347.

Siino, M., Adelfio, G., Mateu, J. and Rodriguez-Cortes, F. J. (2019). Some properties of weighted local second-order statistcs for spatio-temporal point process. Submitted.

Stoyan, D. and Stoyan, H. (1994). Fractals, random shapes, and point fields: methods of geometrical statistics. Chichester: Wiley.


Spatial mark correlation function

Description

Computes an estimator of the spatial mark correlation function.

Usage

kmmr(xyt,s.region,s.lambda,ds,ks="epanech",hs,correction="none",approach="simplified")

Arguments

xyt

Spatial coordinates and times (x,y,t)(x,y,t) of the point pattern.

s.region

Two-column matrix specifying polygonal region containing all data locations.

s.lambda

Vector of values of the spatial intensity function evaluated at the points (x,y)(x,y) in WW. If s.lambda is missing, the estimate of the spatial mark correlation function is computed as for the homogeneous case, i.e. considering n/Wn/|W| as an estimate of the spatial intensity under the parameter approach="standardised".

ds

A vector of distances u at which kmmr(u) is computed.

ks

A kernel function for the spatial distances. The default is the "epanech" kernel. It can also be "box" for the uniform kernel, or "biweight".

hs

A bandwidth of the kernel function ks.

correction

A character vector specifying the edge-correction(s) to be applied among "isotropic", "border", "modified.border", "translate", "setcovf" and "none". The default is "none".

approach

A character vector specifying the approach to use for the estimation to be applied among "simplified" or "standardised". If approach is missing, "simplified" is considered by default.

Details

By default, this command calculates an estimate of the spatial mark correlation function k[mm](r)k_[mm](r) for a spatio-temporal point pattern.

Value

ekmmr

A vector containing the values of k[mm](u)k_[mm](u) estimated.

ds

If ds is missing, a vector of distances u at which kmmr(u) is computed from 0 to until quarter of the maximum distance between the points in the pattern.

kernel

A vector of names and bandwidth of the spatial kernel.

kmmrtheo

Value under the Poisson case is calculated considering τ\tau=max(xyt[,3])-min(xyt[,3]).

Author(s)

Francisco J. Rodriguez Cortes <[email protected]> https://fjrodriguezcortes.wordpress.com

References

Baddeley, A., Rubak, E., Turner, R. (2015). Spatial Point Patterns: Methodology and Applications with R. CRC Press, Boca Raton.

Chiu, S. N., Stoyan, D., Kendall, W. S., and Mecke, J. (2013). Stochastic Geometry and its Applications. John Wiley & Sons.

Gabriel, E., Rowlingson, B., Diggle P J. (2013) stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software 53, 1-29.

Illian, J B., Penttinen, A., Stoyan, H. and Stoyan, D. (2008). Statistical Analysis and Modelling of Spatial Point Patterns. John Wiley and Sons, London.

Stoyan, D., Rodriguez-Cortes, F. J., Mateu, J. and Wilfried, G. (2016). Mark variograms for spatio-temporal point processes, Submitted .

Examples

## Not run:
    #################
    
    # A realisation of spatio-temporal homogeneous Poisson point processes
    hpp <- rpp(lambda = 100, replace = FALSE)$xyt
    
    # R plot
    plot(hpp)
    
    # This function provides an kernel estimator of the spatial mark correlation function
    out <- kmmr(hpp)
    
    # R plot - Spatial mark correlation function
    par(mfrow=c(1,1))
    xl <- c(0,0.25)
    plot(out$ds,out$ekmmr,type="l",xlab="r = distance",ylab=expression(k[mm](r)),
         xlim=xl,col=1,cex.lab=1.5,cex.axis=1.5)
    lines(out$ds,rep(out$kmmrtheo,length(out$ds)),col=11)
    
    ## End(Not run)

Temporal mark correlation function

Description

Computes an estimator of the temporal mark correlation function.

Usage

kmmt(xyt,t.region,t.lambda,dt,kt="epanech",ht,correction="none",approach="simplified")

Arguments

xyt

Spatial coordinates and times (x,y,t)(x,y,t) of the point pattern.

t.region

Vector containing the minimum and maximum values of the time interval.

t.lambda

Vector of values of the temporal intensity function evaluated at the points tt in TT. If t.lambda is missing, the estimate of the temporal mark correlation function is computed as for the homogeneous case, i.e. considering n/Tn/|T| as an estimate of the temporal intensity under the parameter approach="standardised".

dt

A vector of times v at which kmmt(v) is computed.

kt

A kernel function for the temporal distances. The default is the "epanech" kernel. It can also be "box" for the uniform kernel, or "biweight".

ht

A bandwidth of the kernel function kt.

correction

A character vector specifying the edge-correction(s) to be applied among "isotropic", "border", "modified.border", "translate", "setcovf" and "none". The default is "none".

approach

A character vector specifying the approach to use for the estimation to be applied among "simplified" or "standardised". If approach is missing, "simplified" is considered by default.

Details

By default, this command calculates an estimate of the temporal mark correlation function k[mm](t)k_[mm](t) for a spatio-temporal point pattern.

Value

ekmmt

A vector containing the values of k[mm](v)k_[mm](v) estimated.

dt

Parameter passed in argument. If dt is missing, a vector of temporal distances v at which kmmt(v) is computed from 0 to until quarter of the maximum distance between the times in the temporal pattern.

kernel

Parameters passed in argument. A vector of names and bandwidth of the spatial kernel.

kmmttheo

Value under the Poisson case is calculated considering the side lengths of the bounding box of xyt[,1:2].

Author(s)

Francisco J. Rodriguez Cortes <[email protected]> https://fjrodriguezcortes.wordpress.com

References

Baddeley, A., Rubak, E., Turner, R. (2015). Spatial Point Patterns: Methodology and Applications with R. CRC Press, Boca Raton.

Chiu, S. N., Stoyan, D., Kendall, W. S., and Mecke, J. (2013). Stochastic Geometry and its Applications. John Wiley & Sons.

Gabriel, E., Rowlingson, B., Diggle P J. (2013) stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software 53, 1-29.

Illian, J B., Penttinen, A., Stoyan, H. and Stoyan, D. (2008). Statistical Analysis and Modelling of Spatial Point Patterns. John Wiley and Sons, London.

Stoyan, D., Rodriguez-Cortes, F. J., Mateu, J. and Wilfried, G. (2016). Mark variograms for spatio-temporal point processes, Submitted .

Examples

## Not run:
    #################
    
    # A realisation of spatio-temporal homogeneous Poisson point processes
    hpp <- rpp(lambda = 100, replace = FALSE)$xyt
    
    # R plot
    plot(hpp)
    
    # This function provides an kernel estimator of the temporal mark correlation function
    out <- kmmt(hpp)
    
    # R plot - Temporal mark correlation function
    par(mfrow=c(1,1))
    xl <- c(0,0.25)
    plot(out$dt,out$ekmmt,type="l",xlab="t = time",ylab=expression(k[mm](t)),
         xlim=xl,col=1,cex.lab=1.5,cex.axis=1.5)
    lines(out$dt,rep(out$kmmttheo,length(out$dt)),col=11)
    
    ## End(Not run)

Spatial rr-mark function

Description

Computes an estimator of the spatial rr-mark function.

Usage

kmr(xyt,s.region,s.lambda,ds,ks="epanech",hs,correction="none",approach="simplified")

Arguments

xyt

Spatial coordinates and times (x,y,t)(x,y,t) of the point pattern.

s.region

Two-column matrix specifying polygonal region containing all data locations.

s.lambda

Vector of values of the spatial intensity function evaluated at the points (x,y)(x,y) in WW. If s.lambda is missing, the estimate of the spatial mark correlation function is computed as for the homogeneous case, i.e. considering n/Wn/|W| as an estimate of the spatial intensity under the parameter approach="standardised".

ds

A vector of distances u at which kmr(u) is computed.

ks

A kernel function for the spatial distances. The default is the "epanech" kernel. It can also be "box" for the uniform kernel, or "biweight".

hs

A bandwidth of the kernel function ks.

correction

A character vector specifying the edge-correction(s) to be applied among "isotropic", "border", "modified.border", "translate", "setcovf" and "none". The default is "none".

approach

A character vector specifying the approach to use for the estimation to be applied among "simplified" or "standardised". If approach is missing, "simplified" is considered by default.

Details

By default, this command calculates an estimate of the spatial rr-mark function k[m.](r)k_[m.](r) for a spatio-temporal point pattern.

Value

ekmr

A vector containing the values of k[m.](u)k_[m.](u) estimated.

ds

If ds is missing, a vector of distances u at which kmr(u) is computed from 0 to until quarter of the maximum distance between the points in the pattern.

kernel

A vector of names and bandwidth of the spatial kernel.

kmrtheo

Value under the Poisson case is calculated considering τ\tau=max(xyt[,3])-min(xyt[,3]).

Author(s)

Francisco J. Rodriguez Cortes <[email protected]> https://fjrodriguezcortes.wordpress.com

References

Baddeley, A., Rubak, E., Turner, R. (2015). Spatial Point Patterns: Methodology and Applications with R. CRC Press, Boca Raton.

Chiu, S. N., Stoyan, D., Kendall, W. S., and Mecke, J. (2013). Stochastic Geometry and its Applications. John Wiley & Sons.

Gabriel, E., Rowlingson, B., Diggle P J. (2013) stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software 53, 1-29.

Illian, J B., Penttinen, A., Stoyan, H. and Stoyan, D. (2008). Statistical Analysis and Modelling of Spatial Point Patterns. John Wiley and Sons, London.

Stoyan, D., Rodriguez-Cortes, F. J., Mateu, J. and Wilfried, G. (2016). Mark variograms for spatio-temporal point processes, Submitted .

Examples

## Not run:
    #################
    
    # A realisation of spatio-temporal homogeneous Poisson point processes
    hpp <- rpp(lambda = 100, replace = FALSE)$xyt
    
    # R plot
    plot(hpp)
    
    # This function provides an kernel estimator of the spatial r-mark function
    out <- kmr(hpp)
    
    # R plot - Spatial r-mark function
    par(mfrow=c(1,1))
    xl <- c(0,0.25)
    plot(out$ds,out$ekmr,type="l",xlab="r = distance",ylab=expression(k[m.](r)),
         xlim=xl,col=1,cex.lab=1.5,cex.axis=1.5)
    lines(out$ds,rep(out$kmrtheo,length(out$ds)),col=11)
    
    ## End(Not run)

Temporal tt-mark function

Description

Computes an estimator of the temporal tt-mark function.

Usage

kmt(xyt,t.region,t.lambda,dt,kt="epanech",ht,correction="none",approach="simplified")

Arguments

xyt

Spatial coordinates and times (x,y,t)(x,y,t) of the point pattern.

t.region

Vector containing the minimum and maximum values of the time interval.

t.lambda

Vector of values of the temporal intensity function evaluated at the points tt in TT. If t.lambda is missing, the estimate of the temporal mark correlation function is computed as for the homogeneous case, i.e. considering n/Tn/|T| as an estimate of the temporal intensity under the parameter approach="standardised".

dt

A vector of times v at which kmt(v) is computed.

kt

A kernel function for the temporal distances. The default is the "epanech" kernel. It can also be "box" for the uniform kernel, or "biweight".

ht

A bandwidth of the kernel function kt.

correction

A character vector specifying the edge-correction(s) to be applied among "isotropic", "border", "modified.border", "translate", "setcovf" and "none". The default is "none".

approach

A character vector specifying the approach to use for the estimation to be applied among "simplified" or "standardised". If approach is missing, "simplified" is considered by default.

Details

By default, this command calculates an estimate of the temporal tt-mark function k[m.](t)k_[m.](t) for a spatio-temporal point pattern.

Value

ekmt

A vector containing the values of k[m.](v)k_[m.](v) estimated.

dt

Parameter passed in argument. If dt is missing, a vector of temporal distances v at which kmt(v) is computed from 0 to until quarter of the maximum distance between the times in the temporal pattern.

kernel

Parameters passed in argument. A vector of names and bandwidth of the spatial kernel.

kmttheo

Value under the Poisson case is calculated considering the side lengths of the bounding box of xyt[,1:2].

Author(s)

Francisco J. Rodriguez Cortes <[email protected]> https://fjrodriguezcortes.wordpress.com

References

Baddeley, A., Rubak, E., Turner, R. (2015). Spatial Point Patterns: Methodology and Applications with R. CRC Press, Boca Raton.

Chiu, S. N., Stoyan, D., Kendall, W. S., and Mecke, J. (2013). Stochastic Geometry and its Applications. John Wiley & Sons.

Gabriel, E., Rowlingson, B., Diggle P J. (2013) stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software 53, 1-29.

Illian, J B., Penttinen, A., Stoyan, H. and Stoyan, D. (2008). Statistical Analysis and Modelling of Spatial Point Patterns. John Wiley and Sons, London.

Stoyan, D., Rodriguez-Cortes, F. J., Mateu, J. and Wilfried, G. (2016). Mark variograms for spatio-temporal point processes, Submitted .

Examples

## Not run:
    #################
    
    # A realisation of spatio-temporal homogeneous Poisson point processes
    hpp <- rpp(lambda = 100, replace = FALSE)$xyt
    
    # R plot
    plot(hpp)
    
    # This function provides an kernel estimator of the temporal t-mark function
    out <- kmt(hpp)
    
    # R plot - Temporal t-mark function
    par(mfrow=c(1,1))
    xl <- c(0,0.25)
    plot(out$dt,out$ekmt,type="l",xlab="t = time",ylab=expression(k[m.](t)),
         xlim=xl,col=1,cex.lab=1.5,cex.axis=1.5)
    lines(out$dt,rep(out$kmttheo,length(out$dt)),col=11)
    
    ## End(Not run)

Estimation of the Space-Time Inhomogeneous Pair Correlation LISTA functions

Description

Compute an estimate of the space-time pair correlarion LISTA functions.

Usage

LISTAhat(xyt, s.region, t.region, dist, times, lambda,
ks = "box", hs, kt = "box", ht, correction = "isotropic")

Arguments

xyt

Coordinates and times (x,y,t)(x,y,t) of the point pattern.

s.region

Two-column matrix specifying polygonal region containing all data locations. If s.region is missing, the bounding box of xyt[,1:2] is considered.

t.region

Vector containing the minimum and maximum values of the time interval. If t.region is missing, the range of xyt[,3] is considered.

dist

Vector of distances uu at which g(i)(u,v)g^{(i)}(u,v) is computed. If missing, the maximum of dist is given by min(Sx,Sy)/4\min(S_x,S_y)/4, where SxS_x and SyS_y represent the maximum width and height of the bounding box of s.region.

times

Vector of times vv at which g(i)(u,v)g^{(i)}(u,v) is computed. If missing, the maximum of times is given by (TmaxTmin)/4(T_{\max} - T_{\min})/4, where TminT_{\min} and TmaxT_{\max} are the minimum and maximum of the time interval TT.

lambda

Vector of values of the space-time intensity function evaluated at the points (x,y,t)(x,y,t) in S×TS\times T. If lambda is missing, the estimate of the space-time pair correlation function is computed as for the homogeneous case, i.e. considering (n1)/S×T(n-1)/|S \times T| as an estimate of the space-time intensity.

ks

Kernel function for the spatial distances. Default is the "box" kernel. Can also be "epanech" for the Epanechnikov kernel or "gaussian" or "biweight".

hs

Bandwidth of the kernel function ks.

kt

Kernel function for the temporal distances. Default is the "box" kernel. Can also be "epanech" for the Epanechnikov kernel or "gaussian" or "biweight".

ht

Bandwidth of the kernel function kt.

correction

A character vector specifying the edge correction(s) to be applied among "isotropic", "border", "modified.border", "translate" and "none" (see PCFhat). The default is "isotropic".

Details

An individual product density LISTA functions g(i)(.,.)g^{(i)}(.,.) should reveal the extent of the contribution of the event (ui,ti)(u_i,t_i) to the global estimator of the pair correlation function g(.,.)g(.,.), and may provide a further description of structure in the data (e.g., determining events with similar local structure through dissimilarity measures of the individual LISTA functions), for more details see Siino et al. (2017).

Value

A list containing:

list.LISTA

A list containing the values of the estimation of g(i)(r,t)g^{(i)}(r,t) for each one of nn points of the point pattern by matrixs.

listatheo

ndist x ntimes matrix containing theoretical values for a Poisson process.

dist, times

Parameters passed in argument.

kernel

Vector of names and bandwidths of the spatial and temporal kernels.

correction

The name(s) of the edge correction method(s) passed in argument.

Author(s)

Francisco J. Rodriguez-Cortes <[email protected]>

References

Baddeley, A. and Turner, J. (2005). spatstat: An R Package for Analyzing Spatial Point Pattens. Journal of Statistical Software 12, 1-42.

Cressie, N. and Collins, L. B. (2001). Analysis of spatial point patterns using bundles of product density LISA functions. Journal of Agricultural, Biological, and Environmental Statistics 6, 118-135.

Cressie, N. and Collins, L. B. (2001). Patterns in spatial point locations: Local indicators of spatial association in a minefield with clutter Naval Research Logistics (NRL), John Wiley & Sons, Inc. 48, 333-347.

Siino, M., Rodriguez-Cortes, F. J., Mateu, J. and Adelfio, G. (2017). Testing for local structure in spatio-temporal point pattern data. Environmetrics. DOI: 10.1002/env.2463.

Stoyan, D. and Stoyan, H. (1994). Fractals, random shapes, and point fields: methods of geometrical statistics. Chichester: Wiley.


Polygon boundary of north Cumbria

Description

This data set gives the boundary of the county of north Cumbria (UK).

Usage

data(northcumbria)

Format

A matrix containing (x,y)(x,y) coordinates of the boundary.

See Also

fmd for the space-time pattern of food-and-mouth disease in this county in 2001.


Estimation of the Space-Time Inhomogeneous Pair Correlation function

Description

Compute an estimate of the space-time pair correlation function.

Usage

PCFhat(xyt, s.region, t.region, dist, times, lambda,
ks="box", hs, kt="box", ht, correction = "isotropic")

Arguments

xyt

Coordinates and times (x,y,t)(x,y,t) of the point pattern.

s.region

Two-column matrix specifying polygonal region containing all data locations. If s.region is missing, the bounding box of xyt[,1:2] is considered.

t.region

Vector containing the minimum and maximum values of the time interval. If t.region is missing, the range of xyt[,3] is considered.

dist

Vector of distances uu at which g(u,v)g(u,v) is computed. If missing, the maximum of dist is given by min(Sx,Sy)/4\min(S_x,S_y)/4, where SxS_x and SyS_y represent the maximum width and height of the bounding box of s.region.

times

Vector of times vv at which g(u,v)g(u,v) is computed. If missing, the maximum of times is given by (TmaxTmin)/4(T_{\max} - T_{\min})/4, where TminT_{\min} and TmaxT_{\max} are the minimum and maximum of the time interval TT.

lambda

Vector of values of the space-time intensity function evaluated at the points (x,y,t)(x,y,t) in S×TS\times T. If lambda is missing, the estimate of the space-time pair correlation function is computed as for the homogeneous case, i.e. considering n/S×Tn/|S \times T| as an estimate of the space-time intensity.

ks

Kernel function for the spatial distances. Default is the "box" kernel. Can also be "epanech" for the Epanechnikov kernel or "gaussian" or "biweight".

hs

Bandwidth of the kernel function ks.

kt

Kernel function for the temporal distances. Default is the "box" kernel. Can also be "epanech" for the Epanechnikov kernel or "gaussian" or "biweight".

ht

Bandwidth of the kernel function kt.

correction

A character vector specifying the edge correction(s) to be applied among "isotropic", "border", "modified.border", "translate" and "none" (see Details). The default is "isotropic".

Details

An approximately unbiased estimator for the space-time pair correlation function, based on data giving the locations of events xi:i=1,...nx_i: i=1,...n on a spatio-temporal region S×TS \times T, where SS is an arbitrary polygon and TT a time interval:

g^(u,v)=14πui=1nji1wijks(usisj)kt(vtitj)λ(xi)λ(xj),\widehat{g}(u,v)=\frac{1}{4\pi u}\sum_{i=1}^{n}\sum_{j \neq i} \frac{1}{w_{ij}}\frac{k_{s}(u-\|s_i-s_j\|)k_{t}(v-|t_i-t_j|)}{\lambda(x_i) \lambda(x_j)},

where λ(xi)\lambda(x_i) is the intensity at xi=(si,ti)x_i = (s_i,t_i) and wijw_{ij} is an edge correction factor to deal with spatial-temporal edge effects. The edge correction methods implemented are:

isotropic: wij=S×Twij(t)wij(s)w_{ij} = |S \times T| w_{ij}^{(t)} w_{ij}^{(s)}, where the temporal edge correction factor wij(t)=1w_{ij}^{(t)} = 1 if both ends of the interval of length 2titj2 |t_i - t_j| centred at tit_i lie within TT and wij(t)=1/2w_{ij}^{(t)}=1/2 otherwise and wij(s)w_{ij}^{(s)} is the proportion of the circumference of a circle centred at the location sis_i with radius sisj\|s_i -s_j\| lying in SS (also called Ripley's edge correction factor).

border: wij=j=1n1{d(sj,S)>u ; d(tj,T)>v}/λ(xj)1{d(si,S)>u ; d(ti,T)>v}w_{ij}=\frac{\sum_{j=1}^{n}\mathbf{1}\lbrace d(s_j,S)>u \ ; \ d(t_j,T) >v\rbrace/\lambda(x_j)}{\mathbf{1}_{\lbrace d(s_i,S) > u \ ; \ d(t_i,T) >v \rbrace}}, where d(si,S)d(s_i,S) denotes the distance between sis_i and the boundary of SS and d(ti,T)d(t_i,T) the distance between tit_i and the boundary of TT.

modified.border: wij=Su×Tv1{d(si,S)>u ; d(ti,T)>v}w_{ij} = \frac{|S_{\ominus u}|\times|T_{\ominus v}|}{\mathbf{1}_{\lbrace d(s_i,S) > u \ ; \ d(t_i,T) >v \rbrace}}, where SuS_{\ominus u} and TvT_{\ominus v} are the eroded spatial and temporal region respectively, obtained by trimming off a margin of width uu and vv from the border of the original region.

translate: wij=SSsisj×TTtitjw_{ij} =|S \cap S_{s_i-s_j}| \times |T \cap T_{t_i-t_j}|, where SsisjS_{s_i-s_j} and TtitjT_{t_i-t_j} are the translated spatial and temporal regions.

none: No edge correction is performed and wij=S×Tw_{ij}=|S \times T|.

ks()k_s() and kt()k_t() denotes kernel functions with bandwidth hsh_s and hth_t. Experience with pair correlation function estimation recommends box kernels (the default), see Illian et al. (2008). Epanechnikov, Gaussian and biweight kernels are also implemented. Whatever the kernel function, if the bandwidth is missing, a value is obtain from the function dpik of the package KernSmooth. Note that the bandwidths play an important role and their choice is crucial in the quality of the estimators as they heavily influence their variance.

Value

A list containing:

pcf

ndist x ntimes matrix containing values of g^(u,v)\hat{g}(u,v).

pcftheo

ndist x ntimes matrix containing theoretical values for a Poisson process.

dist, times

Parameters passed in argument.

kernel

A vector of names and bandwidths of the spatial and temporal kernels.

correction

The name(s) of the edge correction method(s) passed in argument.

Author(s)

Edith Gabriel <[email protected]>

References

Baddeley, A., Rubak, E., Turner, R., (2015). Spatial Point Patterns: Methodology and Applications with R. CRC Press, Boca Raton.

Gabriel E., Diggle P. (2009). Second-order analysis of inhomogeneous spatio-temporal point process data. Statistica Neerlandica, 63, 43–51.

Gabriel E., Rowlingson B., Diggle P. (2013). stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software, 53(2), 1–29.

Gabriel E. (2014). Estimating second-order characteristics of inhomogeneous spatio-temporal point processes: influence of edge correction methods and intensity estimates. Methodology and computing in Applied Probabillity, 16(2), 411–431.

Illian JB, Penttinen A, Stoyan H and Stoyan, D. (2008). Statistical Analysis and Modelling of Spatial Point Patterns. John Wiley and Sons, London.

Examples

# First example

data(fmd)
data(northcumbria)
FMD<-as.3dpoints(fmd[,1]/1000,fmd[,2]/1000,fmd[,3])
Northcumbria=northcumbria/1000

# estimation of the temporal intensity
Mt<-density(FMD[,3],n=1000)
mut<-Mt$y[findInterval(FMD[,3],Mt$x)]*dim(FMD)[1]

# estimation of the spatial intensity
h<-mse2d(as.points(FMD[,1:2]), Northcumbria, nsmse=50, range=4)
h<-h$h[which.min(h$mse)]
Ms<-kernel2d(as.points(FMD[,1:2]), Northcumbria, h, nx=500, ny=500)
atx<-findInterval(x=FMD[,1],vec=Ms$x)
aty<-findInterval(x=FMD[,2],vec=Ms$y)
mhat<-NULL
for(i in 1:length(atx)) mhat<-c(mhat,Ms$z[atx[i],aty[i]])

# estimation of the pair correlation function
g1 <- PCFhat(xyt=FMD, dist=1:15, times=1:15, lambda=mhat*mut/dim(FMD)[1],
 s.region=northcumbria/1000,t.region=c(1,200))

# plotting the estimation 

plotPCF(g1)
plotPCF(g1,type="persp",theta=-65,phi=35) 


# Second example

xyt=rpp(lambda=200)
g2=PCFhat(xyt$xyt,dist=seq(0,0.16,by=0.02),
times=seq(0,0.16,by=0.02),correction=c("border","translate"))

plotPCF(g2,type="contour",which="border")

Plot for spatio-temporal point objects

Description

This function plot either xyxy-locations and cumulative distribution of the times, or a space-time 3D scatter, or the time-mark and space-mark of the spatio-temporal point pattern, through arguments style and type.

It can also plot xyxy-locations with time treated as a quantitative mark attached to each location, as in the previous version of the function, through argument mark (see stpp version < 2.0.0).

Usage

## S3 method for class 'stpp'
plot(x, s.region=NULL, t.region=NULL, style="generic", type="projection",
mark=NULL , mark.cexmin=0.4, mark.cexmax=1.2, mark.col=1, ...)

Arguments

x

Any object of class stpp in spatio-temporal point format.

s.region

Two-column matrix specifying polygonal region containing all data locations. If s.region is missing, the default limits are considered.

t.region

Vector containing the minimum and maximum values of the time interval. If t.region is missing, the default limits are considered.

type

Specify the kind of graphical representation. If type="projection" (default) the function plot the xy-locations and cumulative distribution of the times. If type="mark" the function plot the time-mark and space-mark. If type="scatter" the function plot space-time 3D scatter.

style

Two different classes of graphic styles can be chosen. If style="generic" (default) the graphics are plot by default function plot in R and if style="elegant" the graphics are plot based on the R packages ggplot2 and plot3D.

mark

Logical. If NULL (default), xy-locations and cumulative distribution of the times are plotted. If TRUE, the time is treated as a quantitative mark attached to each location, and the locations are plotted with the size and/or colour of the plotting symbol determined by the value of the mark.

mark.cexmin, mark.cexmax

Range of the size of the plotting symbol when mark=TRUE.

mark.col

Colour of the plotting symbol when mark=TRUE. If mark.col=0, all locations have the same colour specified by the usual col argument. Otherwise, can be 1 or "black" (default), 2 or "red", 3 or "green", 4 or "blue", in which cases symbols colour is faded, and the darker corresponds to the most recent time.

...

Further arguments to be passed to the functions plot and scatter3D. Typical arguments are pch, theta and phi.

Value

None

Author(s)

Edith Gabriel <[email protected]> and Francisco J. Rodriguez-Cortes.

References

Gabriel E., Rowlingson B., Diggle P. (2013). stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software, 53(2), 1–29.

Stoyan, D., Rodriguez-Cortes, F. J., Mateu, J., and Gille, W. (2017). Mark variograms for spatio-temporal point processes. Spatial Statistics. 20, 125-147.

See Also

as.3dpoints for creating data in spatio-temporal point format.


Plot the estimation of the Space-Time Inhomogeneous K-function

Description

Contour plot or perspective plot or image of the Space-Time Inhomogeneous K-function estimate.

Usage

plotK(K,n=15,L=FALSE,type="contour",legend=TRUE,which=NULL,
main=NULL,...)

Arguments

K

Result of the STIKhat function.

n

Number of contour levels desired.

L

Logical indicating whether KST(u,v)K_{ST}(u,v) or L(u,v)=KST(u,v)πu2vL(u,v)=K_{ST}(u,v)-\pi u^2 v must be plotted.

type

Specifies the kind of plot: contour by default, but can also be persp or image

legend

Logical indicating whether a legend must be added to the plot.

which

A character specifying the edge correction among the ones used in STIKhat. If a single edge correction method was used in STIKhat, it is not necessary to specify which.

main

Plot title.

...

Additional arguments to persp if persp=TRUE, such as theta and phi.

Author(s)

Edith Gabriel <[email protected]>

See Also

contour, persp, image and STIKhat for an example.


Plot the estimation of the Space-Time Inhomogeneous Pair Correlation function

Description

Contour, image or perspective plot of the Space-Time Inhomogeneous Pair correlation function estimate.

Usage

plotPCF(PCF,n=15,type="contour",legend=TRUE,which=NULL,
main=NULL,...)

Arguments

PCF

Result of the PCFhat function.

n

Number of contour levels desired.

type

Specifies the kind of plot: contour by default, but can also be persp or image

legend

Logical indicating whether a legend must be added to the plot.

which

A character specifying the edge correction among the ones used in PCFhat. If a single edge correction method was used in PCFhat, it is not necessary to specify which.

main

Plot title.

...

Additional arguments to persp if persp=TRUE, such as theta and phi.

Author(s)

Edith Gabriel <[email protected]>

See Also

contour, persp, image and PCFhat for an example.


Generate infection point patterns

Description

Generate one (or several) realisation(s) of the infection process in a region S×TS\times T.

Usage

rinfec(npoints, s.region, t.region, nsim=1, alpha, beta, gamma, 
s.distr="exponential", t.distr="uniform", maxrad, delta, h="step", 
g="min", recent=1, lambda=NULL, lmax=NULL, nx=100, ny=100, nt=1000, 
t0, inhibition=FALSE, ...)

Arguments

npoints

Number of points to simulate.

s.region

Two-column matrix specifying polygonal region containing all data locations. If s.region is missing, the unit square is considered.

t.region

Vector containing the minimum and maximum values of the time interval. If t.region is missing, the interval [0,1][0,1] is considered.

nsim

Number of simulations to generate. Default is 1.

alpha

Numerical value for the latent period.

beta

Numerical value for the maximum infection rate.

gamma

Numerical value for the infection period.

h

Infection rate function which depends on alpha, beta and delta. Must be choosen among "step" and "gaussian".

s.distr

Spatial distribution. Must be choosen among "uniform", "gaussian", "exponential" and "poisson".

t.distr

Temporal distribution. Must be choosen among "uniform" and "exponential".

maxrad

Single value or 2-vector of spatial and temporal maximum radiation respectively. If single value, the same value is used for space and time.

delta

Spatial distance of inhibition/contagion. If missing, the spatial radiation is used.

g

Compute the probability of acceptance of a new point from h and recent. Must be choosen among "min", "max" and "prod".

recent

If “all” consider all previous events. If is an integer, say NN, consider only the NN most recent events.

lambda

Function or matrix defining the intensity of a Poisson process if s.distr is Poisson.

lmax

Upper bound for the value of lambda.

nx, ny

Define the 2-D grid on which the intensity is evaluated if s.distr is Poisson.

nt

Used to discretize time to compute the infection rate function.

t0

Minimum time used to compute the infection rate function. Default is the minimum of t.region.

inhibition

Logical. If TRUE, an inhibition process is generated. Otherwise, it is a contagious process.

...

Additional parameters if lambda is a function.

Value

A list containing:

xyt

Matrix (or list of matrices if nsim>1) containing the points (x,y,t)(x,y,t) of the simulated point pattern. xyt (or any element of the list if nsim>1) is an object of the class stpp.

s.region, t.region

Parameters passed in argument.

Author(s)

Edith Gabriel <[email protected]>, Peter J Diggle.

See Also

plot.stpp, animation and stan for plotting space-time point patterns.

Examples

# inhibition; spatial distribution: uniform
inf1 = rinfec(npoints=100, alpha=0.2, beta=0.6, gamma=0.5,
maxrad=c(0.075,0.5), t.region=c(0,50), s.distr="uniform", 
t.distr="uniform", h="gaussian", p="min", recent="all", t0=0.02, 
inhibition=TRUE)
plot(inf1$xyt, style="elegant")


# contagion; spatial distribution: Poisson with intensity a given matrix
data(fmd)
data(northcumbria)
h = mse2d(as.points(fmd[,1:2]), northcumbria, nsmse=30, range=3000)
h = h$h[which.min(h$mse)]
Ls = kernel2d(as.points(fmd[,1:2]), northcumbria, h, nx=50, ny=50)
inf2 = rinfec(npoints=100, alpha=4, beta=0.6, gamma=20, maxrad=c(12000,20), 
s.region=northcumbria, t.region=c(1,2000), s.distr="poisson", 
t.distr="uniform", h="step", p="min", recent=1, 
lambda=Ls$z, inhibition=FALSE)

image(Ls$x, Ls$y, Ls$z, col=grey((1000:1)/1000)); polygon(northcumbria,lwd=2)
animation(inf2$xyt, add=TRUE, cex=0.7, runtime=15)

Generate interaction point patterns

Description

Generate one (or several) realisation(s) of the inhibition or contagious process in a region S×TS\times T.

Usage

rinter(npoints,s.region,t.region,hs="step",gs="min",thetas=0,
 deltas,ht="step",gt="min",thetat=1,deltat,recent="all",nsim=1,
 discrete.time=FALSE,replace=FALSE,inhibition=TRUE,...)

Arguments

npoints

Number of points to simulate.

s.region

Two-column matrix specifying polygonal region containing all data locations. If s.region is missing, the unit square is considered.

t.region

Vector containing the minimum and maximum values of the time interval. If t.region is missing, the interval [0,1][0,1] is considered.

hs, ht

Function which depends on the distance between points and theta. Can be chosen among "step" and "gaussian" or can refer to a user defined function which only depend on d, theta, and delta (see details). If inhibition=TRUE, h is monotone, increasing, and must tend to 1 when the distance tends to infinity. 0 \leqh(d,theta)\leq 1. Otherwise, h is monotone, decreasing, and must tend to 1 when the distance tends to 0.

thetas, thetat

Parameters of hs and ht functions.

deltas, deltat

Spatial and temporal distance of inhibition.

gs, gt

Compute the probability of acceptance of a new point from hs or ht and recent. Must be choosen among "min", "max" and "prod".

recent

If “all” consider all previous events. If is an integer, say NN, consider only the NN most recent events.

nsim

Number of simulations to generate. Default is 1.

discrete.time

If TRUE, times belong to NN, otherwise belong to R+{\bf R}^+.

replace

Logical. If TRUE allows times repeat.

inhibition

Logical. If TRUE, an inhibition process is generated. Otherwise, it is a contagious process.

...

Additional parameters if hs and ht are defined by the user.

Value

A list containing:

xyt

Matrix (or list of matrices if nsim>1) containing the points (x,y,t)(x,y,t) of the simulated point pattern. xyt (or any element of the list if nsim>1) is an object of the class stpp.

s.region, t.region

Parameters passed in argument.

Author(s)

Edith Gabriel <[email protected]>, Peter J Diggle.

See Also

plot.stpp, animation and stan for plotting space-time point patterns.

Examples

# simple inhibition process
inh1 = rinter(npoints=200,thetas=0,deltas=0.05,thetat=0,deltat=0.001,
inhibition=TRUE)
plot(inh1$xyt,style="elegant")


# inhibition process using hs and ht defined by the user
hs = function(d,theta,delta,mus=0.1)
{
 res=NULL
 a=(1-theta)/mus
 b=theta-a*delta
 for(i in 1:length(d))
	{	
	if (d[i]<=delta) res=c(res,theta)
	if (d[i]>(delta+mus)) res=c(res,1)
	if (d[i]>delta & d[i]<=(delta+mus)) res=c(res,a*d[i]+b)
	}
 return(res)
}
ht = function(d,theta,delta,mut=0.3)
{
 res=NULL
 a=(1-theta)/mut
 b=theta-a*delta
 for(i in 1:length(d))
	{	
	if (d[i]<=delta) res=c(res,theta)
	if (d[i]>(delta+mut)) res=c(res,1)
	if (d[i]>delta & d[i]<=(delta+mut)) res=c(res,a*d[i]+b)
	}
 return(res)
}
d=seq(0,1,length=100)
plot(d,hs(d,theta=0.2,delta=0.1,mus=0.1),xlab="",ylab="",type="l",
ylim=c(0,1),lwd=2,las=1)
lines(d,ht(d,theta=0.1,delta=0.05,mut=0.3),col=2,lwd=2)
legend("bottomright",col=1:2,lty=1,lwd=2,legend=c(expression(h[s]),
expression(h[t])),bty="n",cex=2)

inh2 = rinter(npoints=100, hs=hs, gs="min", thetas=0.2, deltas=0.1, 
ht=ht, gt="min", thetat=0.1, deltat=0.05, inhibition=TRUE)
animation(inh2$xyt, runtime=15, cex=0.8)

# simple contagious process for given spatial and temporal regions
data(northcumbria)
cont1 = rinter(npoints=100, s.region=northcumbria, t.region=c(1,200), 
thetas=0, deltas=10000, thetat=0, deltat=10, recent=1, inhibition=FALSE)
plot(cont1$xyt,pch=19,s.region=cont1$s.region,mark=TRUE,mark.col=4)

Generate log-Gaussian Cox point patterns

Description

Generate one (or several) realisation(s) of the log-Gaussian cox process in a region S×TS\times T.

Usage

rlgcp(s.region, t.region, replace=TRUE, npoints=NULL, nsim=1, 
 nx=100, ny=100, nt=100,separable=TRUE,model="exponential",
 param=c(1,1,1,1,1,1), scale=c(1,1),var.grf=1,mean.grf=0,
 lmax=NULL,discrete.time=FALSE,exact=FALSE,anisotropy=FALSE,ani.pars=NULL)

Arguments

s.region

Two-column matrix specifying polygonal region containing all data locations. If s.region is missing, the unit square is considered.

t.region

Vector containing the minimum and maximum values of the time interval. If t.region is missing, the interval [0,1][0,1] is considered.

npoints

Number of points to simulate. If NULL, the number of points is from a Poisson distribution with mean the double integral of λ(s,t)\lambda(s,t) over s.region and t.region.

nsim

number of simulations to generate. Default is 1.

separable

Logical. If TRUE, the covariance function of the Gaussian random field is separable.

model

Vector of length 1 or 2 specifying the model(s) of covariance of the Gaussian random field. If separable=TRUE and model is of length 2, then the elements of model define the spatial and temporal covariances respectively. If separable=TRUE and model is of length 1, then the spatial and temporal covariances belongs to the same class of covariances, among "matern", "exponential", "stable", "cauchy" and "wave" (see Details). If separable=FALSE, model must be of length 1 and is either "gneiting" or "cesare" (see Details).

param

(α1,α2,α3,α4,α5,α6)(\alpha_1,\alpha_2,\alpha_3,\alpha_4,\alpha_5,\alpha_6). Vector of parameters of the covariance function (see Details).

scale

Vector of length 2 defining the spatial and temporal scale.

var.grf

Variance of the Gaussian random field.

mean.grf

Mean of the Gaussian random field.

replace

Logical allowing times repeat.

nx, ny, nt

Define the size of the 3-D grid on which the intensity is evaluated.

lmax

Upper bound for the value of λ(x,y,t)\lambda(x,y,t).

discrete.time

If TRUE, times belong to NN, otherwise belong to R+R^+.

exact

logical allowing exact simulation of Gaussian random fields (see manual for details).

anisotropy

If TRUE, simulate an anisotropic point pattern. Currently only implemented for separable covariance functions.

ani.pars

Vector of length 2, the anisotropy angle and the anisotropy ratio, respectively (see details).

Details

We implemented stationary, isotropic spatio-temporal covariance functions.

Separable covariance functions

c(h,t)=cs(h)ct(t),hS,tTc(h,t) = c_s(\| h \|) \, c_t(|t|) , h \in S, t \in T

The purely spatial and purely temporal covariance functions can be:

  • Exponential: c(r)=exp(r)c(r) = \exp(-r),

  • Stable: c(r)=exp(rα)c(r) = \exp(-r^\alpha), α[0,2]\alpha \in [0,2],

  • Cauchy: c(r)=(1+r2)αc(r) = (1+r^2)^{-\alpha}, α>0\alpha >0,

  • Wave: c(r)=sin(r)rc(r) = \frac{\sin(r)}{r} if r>0r>0, c(0)=1c(0)=1,

  • Matern: c(r)=(αr)ν2ν1Γ(ν)Kν(αr)c(r) = \frac{(\alpha r)^\nu}{2^{\nu-1}\Gamma(\nu)} {\cal K}_{\nu}(\alpha r), ν>0\nu > 0 and α>0\alpha > 0.

    Kν{\cal K}_{\nu} is the modified Bessel function of second kind:

    Kν(x)=π2Iν(x)Iν(x)sin(πν),{\cal K}_{\nu}(x) = \frac{\pi}{2} \frac{I_{-\nu}(x) - I_{\nu}(x)}{\sin(\pi \nu)},

    with Iν(x)=(x2)νk=01k!Γ(ν+k+1)(x2)2kI_{\nu}(x) = \left( \frac{x}{2} \right)^{\nu} \sum_{k=0}^\infty \frac{1}{k! \Gamma(\nu+k+1)} \left( \frac{x}{2} \right)^{2k}.

    The parameters α1\alpha_1 and α2\alpha_2 correspond to the parameters of the spatial and temporal covariance respectively. For the Matern model, the parameters α1\alpha_1, α3\alpha_3 and α2\alpha_2, α4\alpha_4 correspond to the parameters ν\nu, α\alpha of the spatial and temporal covariance.

Non-separable covariance functions

The spatio-temporal covariance function can be:

  • Gneiting: c(h,t)=ψ(t2/β2)α6ϕ(h2/β1ψ(t2/β2))c(h,t) = \psi (t^2/\beta_2)^{-\alpha_6} \phi \left(\frac{h^2/ \beta_1}{\psi (t^2/\beta_2)} \right), β1,β2>0\beta_1, \beta_2 >0 are spatial and temporal scales respectively,

    • If α2=1\alpha_2=1, ϕ(r)\phi(r) is the Stable model.

    • if α2=2\alpha_2=2, ϕ(r)\phi(r) is the Cauchy model.

    • If α2=3\alpha_2=3, ϕ(r)\phi(r) is the Matern model.

    • If α5=1\alpha_5=1, ψ(r)=(rα3+1)α4\psi(r) = (r^{\alpha_3}+ 1)^{\alpha_4},

    • If α5=2\alpha_5=2, ψ(r)=(α41rα3+1)/(rα3+1)\psi(r) = (\alpha_4^{-1} r^{\alpha_3} +1)/(r^{\alpha_3}+1),

    • If α5=3\alpha_5=3, ψ(r)=log(rα3+α4)/logα4\psi(r) = \log(r^{\alpha_3} + \alpha_4)/\log {\alpha_4},

    The parameter α1\alpha_1 is the respective parameter for the model of ϕ()\phi(\cdot), α3(0,1]\alpha_3 \in (0,1], α4(0,1]\alpha_4 \in (0,1] and α62\alpha_6 \geq 2.

  • cesare: c(h,t)=(1+(h/β1)α1+(t/β2)α2)α3c(h,t) = \left( 1 + (h/\beta_1)^{\alpha_1} + (t/\beta_2)^{\alpha_2} \right)^{-\alpha_3}, β1,β2>0\beta_1, \beta_2 >0, α1,α2[1,2]\alpha_1, \alpha_2 \in [1,2] and α33/2\alpha_3 \geq 3/2.

We also implemented anisotropic Log-Gaussian Cox processes. We considered geometric spatial anisotropy (see Moller and Toftaker, 2014). In this case the covariance function is elliptical and anisotropy is characterized by two parameters: the anisotropy angle 0θ<π0 \leq \theta < \pi and the anisotropy ratio 0<δ10 < \delta \leq 1 of the minor axis 2ωδ2 \omega \delta and the major axis 2ω2 \omega.

C(h,t)=C0(hΣ1h,t), hR2.C(h,t)=C_0\left( \sqrt{h \Sigma^{-1} h'},t \right), \ h \in R^2.

Value

A list containing:

xyt

Matrix (or list of matrices if nsim>1) containing the points (x,y,t)(x,y,t) of the simulated point pattern. xyt (or any element of the list if nsim>1) is an object of the class stpp.

s.region, t.region

parameters passed in argument.

Lambda

nx×ny×ntnx \times ny \times nt array (or list of array if nsim>1) of the intensity.

Author(s)

Edith Gabriel <[email protected]>, Peter J Diggle.

References

Chan, G. and Wood A. (1997). An algorithm for simulating stationary Gaussian random fields. Applied Statistics, Algorithm Section, 46, 171–181.

Chan, G. and Wood A. (1999). Simulation of stationary Gaussian vector fields. Statistics and Computing, 9, 265–268.

Gneiting T. (2002). Nonseparable, stationary covariance functions for space-time data. Journal of the American Statistical Association, 97, 590–600.

Moller J. and Toftaker H. (2014). Geometric anisotropic spatial point pattern analysis and Cox processes. Scandinavian Journal of Statistics, 41, 414–435.

See Also

plot.stpp, animation and stan for plotting space-time point patterns.

Examples

# non separable covariance function: 
lgcp1 <- rlgcp(npoints=200, nx=50, ny=50, nt=50, separable=FALSE, 
model="gneiting", param=c(1,1,1,1,1,2), var.grf=1, mean.grf=0)
N <- lgcp1$Lambda[,,1];for(j in 2:(dim(lgcp1$Lambda)[3])){N <-
N+lgcp1$Lambda[,,j]}
image(N,col=grey((1000:1)/1000));box()
animation(lgcp1$xyt, cex=0.8, runtime=10, add=TRUE, prevalent="orange")

# separable covariance function: 
lgcp2 <- rlgcp(npoints=200, nx=50, ny=50, nt=50, separable=TRUE, 
model="exponential", param=c(1,1,1,1,1,2), var.grf=2, mean.grf=-0.5*2)
N <- lgcp2$Lambda[,,1];for(j in 2:(dim(lgcp2$Lambda)[3])){N <-
N+lgcp2$Lambda[,,j]}
image(N,col=grey((1000:1)/1000));box()
animation(lgcp2$xyt, cex=0.8, pch=20, runtime=10, add=TRUE,
prevalent="orange")

# anisotropic

sigma2=0.5
simlgcp <- rlgcp(npoints=500,nx=250, ny=200, nt=50,separable=TRUE,
s.region=matrix(c(0,2,2,0,0,0,0.5,0.5),byrow=FALSE,ncol=2), model="exponential", 
param=c(1,1,1,1,1,2), var.grf=sigma2, mean.grf=-0.5*sigma2,anisotropy = TRUE,
ani.pars = c(pi/4,0.1))

N <- simlgcp$Lambda[,,1];for(j in 2:dim(simlgcp$Lambda)[3]){N <- N+simlgcp$Lambda[,,j]}
image(x=simlgcp$grid[[1]]$x,y=simlgcp$grid[[1]]$y,z=N,col=grey((1000:1)/1000));box()
points(simlgcp$xyt[,1:2],pch=19,cex=0.25,col=2)

Generate Poisson cluster point patterns

Description

Generate one (or several) realisation(s) of the Poisson cluster process in a region S×TS\times T.

Usage

rpcp(s.region, t.region, nparents=NULL, npoints=NULL, lambda=NULL, 
 mc=NULL, nsim=1, cluster="uniform", dispersion, infectious=TRUE, 
 edge = "larger.region", larger.region=larger.region, tronc=1,...)

Arguments

s.region

Two-column matrix specifying polygonal region containing all data locations. If s.region is missing, the unit square is considered.

t.region

Vector containing the minimum and maximum values of the time interval. If t.region is missing, the interval [0,1][0,1] is considered.

nparents

Number of parents. If NULL, nparents is from a Poisson distribution with intensity lambda.

npoints

Number of points to simulate. If NULL (default), the number of points is from a Poisson distribution with mean the double integral of the intensity over s.region and t.region.

lambda

Intensity of the parent process. Can be either a numeric value, a function, or a 3d-array (see rpp). If NULL, it is constant and equal to nparents / volume of the domain.

mc

Average number of children per parent. It is used when npoints is NULL.

nsim

Number of simulations to generate.

cluster

Distribution of children: “uniform”, “normal” and “exponential” are currently implemented. Either a single value if the distribution in space and time is the same, or a vector of length 2, giving first the spatial distribution of children and then the temporal distribution.

dispersion

Scale parameter. It equals twice the standard deviation of location of children relative to their parent for a normal distribution of children; the mean for an exponential distribution and half range for an uniform distribution.

infectious

If TRUE, offspring's times are always greater than parent's time.

edge

Specify the edge correction to use "larger.region" or "without".

larger.region

By default, the larger spatial region is the convex hull of s.region enlarged by the spatial related value of dispersion and the larger time interval is t.region enlarged by the temporal related value of dispersion. One can over-ride default using the 2-vector parameter larger.region.

tronc

Parameter of the truncated exponential distribution for the distribution of children.

...

Additional parameters of the intensity of the parent process.

Value

A list containing:

xyt

Matrix (or list of matrices if nsim>1) containing the points (x,y,t)(x,y,t) of the simulated point pattern. xyt (or any element of the list if nsim>1) is an object of the class stpp.

s.region, t.region

Parameters passed in argument.

Author(s)

Edith Gabriel <[email protected]>, Peter J Diggle.

See Also

plot.stpp, animation and stan for plotting space-time point patterns.

Examples

# homogeneous Poisson distribution of parents

data(northcumbria)
pcp1 <- rpcp(nparents=50, npoints=500, s.region=northcumbria, 
t.region=c(1,365), cluster=c("normal","exponential"), 
maxrad=c(5000,5))

animation(pcp1$xyt, s.region=pcp1$s.region, t.region=pcp1$t.region,
runtime=5)

# inhomogeneous Poisson distribution of parents

lbda <- function(x,y,t,a){a*exp(-4*y) * exp(-2*t)}
pcp2 <- rpcp(nparents=50, npoints=500, cluster="normal", lambda=lbda, 
a=4000/((1-exp(-4))*(1-exp(-2))))
plot(pcp2$xyt, style="elegant")

Generate Poisson point patterns

Description

Generate one (or several) realisation(s) of the (homogeneous or inhomogeneous) Poisson process in a region S×TS\times T.

Usage

rpp(lambda, s.region, t.region, npoints=NULL, nsim=1, replace=TRUE,
    discrete.time=FALSE, nx=100, ny=100, nt=100, lmax=NULL, ...)

Arguments

lambda

Spatio-temporal intensity of the Poisson process. If lambda is a single positive number, the function generates realisations of a homogeneous Poisson process, whilst if lambda is a function of the form λ(x,y,t,)\lambda(x,y,t,\dots) or a 3D-array it generates realisations of an inhomogeneous Poisson process.

s.region

Two-column matrix specifying polygonal region containing all data locations. If s.region is missing, the unit square is considered.

t.region

Vector containing the minimum and maximum values of the time interval. If t.region is missing, the interval [0,1][0,1] is considered.

replace

Logical allowing times repeat (should only be used when discrete.time=TRUE).

npoints

Number of points to simulate. If NULL, the number of points is from a Poisson distribution with mean the double integral of lambda over s.region and t.region.

discrete.time

If TRUE, times belong to N{\bf N}, otherwise belong to R+{\bf R}^+.

nsim

Number of simulations to generate. Default is 1.

nx, ny, nt

Define the size of the 3-D grid on which the intensity is evaluated.

lmax

Upper bound for the value of λ(x,y,t)\lambda(x,y,t), if lambda is a function.

...

Additional parameters if lambda is a function.

Value

A list containing:

xyt

Matrix (or list of matrices if nsim>1) containing the points (x,y,t)(x,y,t) of the simulated point pattern. xyt (or any element of the list if nsim>1) is an object of the class stpp.

Lambda

nx×ny×ntnx \times ny \times nt array of the intensity surface at each time.

s.region, t.region, lambda

parameters passed in argument.

Author(s)

Edith Gabriel <[email protected]> and Peter J Diggle.

See Also

plot.stpp, animation and stan for plotting space-time point patterns.

Examples

# Homogeneous Poisson process
# ---------------------------
hpp1 <- rpp(lambda=200,replace=FALSE)

stan(hpp1$xyt)

# fixed number of points, discrete time, with time repeat.
data(northcumbria)
hpp2 <- rpp(npoints=500, s.region=northcumbria, t.region=c(1,1000), 
discrete.time=TRUE)
plot(hpp2$xyt, style="elegant")

polymap(northcumbria)
animation(hpp2$xyt, s.region=hpp2$s.region, t.region=hpp2$t.region, 
runtime=10, add=TRUE)



# Inhomogeneous Poisson process
# -----------------------------

# intensity defined by a function
lbda1 = function(x,y,t,a){a*exp(-4*y) * exp(-2*t)}
ipp1 = rpp(lambda=lbda1, npoints=400, a=3200/((1-exp(-4))*(1-exp(-2))))
stan(ipp1$xyt)

# intensity defined by a matrix
data(fmd)
data(northcumbria)
h = mse2d(as.points(fmd[,1:2]), northcumbria, nsmse=30, range=3000)
h = h$h[which.min(h$mse)]
Ls = kernel2d(as.points(fmd[,1:2]), northcumbria, h, nx=100, ny=100)
Lt = dim(fmd)[1]*density(fmd[,3], n=200)$y
Lst=array(0,dim=c(100,100,200))
for(k in 1:200) Lst[,,k] <- Ls$z*Lt[k]/dim(fmd)[1]
ipp2 = rpp(lambda=Lst, s.region=northcumbria, t.region=c(1,200), 
discrete.time=TRUE)
           
par(mfrow=c(1,1))
image(Ls$x, Ls$y, Ls$z, col=grey((1000:1)/1000)); polygon(northcumbria)
animation(ipp2$xyt, add=TRUE, cex=0.5, runtime=15)

Generate spatio-temporal point patterns

Description

Generate one (or several) realisation(s) of a spatio-temporal point process in a region S×TS\times T.

Usage

sim.stpp(class="poisson", s.region, t.region, npoints=NULL, 
nsim=1, ...)

Arguments

class

Must be chosen among "poisson", "cluster", "cox", "infectious" and "inhibition".

s.region

Two-column matrix specifying polygonal region containing all data locations. If s.region is missing, the unit square is considered.

t.region

Vector containing the minimum and maximum values of the time interval. If t.region is missing, the interval [0,1][0,1] is considered.

npoints

Number of points to simulate.

nsim

Number of simulations to generate. Default is 1.

...

Additional parameters related to the class parameter. See rpp for the Poisson process; rpcp for the Poisson cluster process; rlgcp for the Log-Gaussian Cox process; rinter for the interaction (inhibition or contagious) process and rinfec for the infectious process.

Value

A list containing:

xyt

Matrix (or list of matrices if nsim>1) containing the points (x,y,t)(x,y,t) of the simulated point pattern. xyt (or any element of the list if nsim>1) is an object of the class stpp.

s.region, t.region

Parameters passed in argument.

Author(s)

Edith Gabriel <[email protected]>

See Also

rpp, rinfec, rinter, rpcp and rlgcp for the simulation of Poisson, infectious, interaction, Poisson cluster and log-gaussian Cox processes respectively; and plot.stpp, animation and stan for plotting space-time point patterns.


(3D) space-time data animation

Description

Displays (x,y,t)(x,y,t) point data and enables dynamic highlighting of time slices.

Usage

stan(xyt,tlim=range(xyt[,3],na.rm=TRUE),twid=diff(tlim)/20,
persist=FALSE,states,bgpoly,bgframe=TRUE,bgimage,
bgcol=gray(seq(0,1,len=12)),axes=TRUE)

Arguments

xyt

A 3-column matrix of xx, yy, tt coordinates

tlim

A two-element vector of upper and lower time limits

twid

The initial time window width

persist

Whether to display points before time window

states

How to display points - see Details

bgpoly

A polygon to draw on the background plane

bgframe

Whether to extend the bgpoly to the front plane

bgimage

An list with xx, yy vectors and zz matrix to display on the background plane

bgcol

A colour palette vector with which to draw the bgimage

axes

Logical value indicating whether labels should be added.

Details

This function requires the rpanel and rgl packages. It uses rpanel for the sliders to control the graphics, and rgl for its ability to do flicker-free graphics.

The sliders set the position and width of the temporal highlight window. For 'time' slider set to time TT and 'width' slider set to SS, highlighted points are those with time coordinate tt such that TS<t<TT-S< t< T.

How points are shown is configured with the states parameter. This is a list of length 3 specifying how points before the time window, inside the time window, and after the time window are displayed. Each element is a list of parameters as would be passed to material3d() together with a radius element. Points are drawn as spheres with the corresponding material and radius as a fraction of the spatial span of the data.

By default the third state is invisible, and the first two states are different. By calling with the default for states and persist=TRUE, then the first state is set to the same as the second state. This has the effect of showing all points at time <T< T with the same sphere type.

If the user specifies the states parameter, then persist is ignored. The user can emulate the persist behaviour by specifying a states list with identical parameters for states 1 and 2.

Note that each state element should specify all material3d parameters used in any of the state elements. This is to make sure the parameters are reset for each of the sets of points.

The background polygon must be a simple 2-column vector of xx and yy coordinates. When used with bgframe=TRUE, the polygon is also drawn on the front plane, and the convex hull points are connected front to back in order to visualise the space-time prism that the data are contained in.

A raster image can be displayed on the back plane by setting the bgimage parameter. This must be a list with xx, yy and zz components as needed by the image function. Note that xx and yy define the center of cells and so must be the same length as the dimensions of zz - the image function can accept xx and yy values that are one longer than the dimensions of zz to define the edges, but bgimage does not allow that.

Value

A list of the slider parameters when the dialog is quitted.

Author(s)

Barry Rowlingson <[email protected]>, Edith Gabriel


Generate double-cluster point pattern

Description

Generate a realisation of the double-cluster process in a region S×TS\times T.

Usage

stdcpp(lambp, a, b, c, mu, s.region, t.region)

Arguments

s.region

Two-column matrix specifying polygonal region containing all data locations.If s.region is missing, the unit square is considered.

t.region

Vector containing the minimum and maximum values of the time interval. If t.region is missing, the interval [0,1][0,1] is considered.

lambp

Intensity of the parent process. Can be either a numeric value, a function, or a 3d-array (see rpp).

a

Length of the semi-axes xx of ellipsoid.

b

Length of the semi-axes yy of ellipsoid.

c

Length of the semi-axes yy of ellipsoid.

mu

Average number of daughter per parent. (a single positive number).

Details

We consider the straightforward extension of the classical Matern cluster process on the R3R^3 case (with ellipsoid or balls) by considering the zz-coordiantes as times.

Consider a Poisson point process in the plane with intensity λp\lambda_p as cluster centres for all times 'parent', as well as a ellipsoid (or ball) where the semi-axes are of lengths aa, bb and cc, around of each Poisson point under a random general rotation. The scatter uniformly in all ellipsoid (or ball) of all points which are of the form (x,y,z)(x,y,z), the number of points in each cluster being random with a Poisson (μ\mu) distribution. The resulting point pattern is a spatio-temporal cluster point process with t=zt=z. This point process has intensity λp×μ\lambda_{p} \times \mu.

Value

The simulated spatio-temporal point pattern.

Author(s)

Francisco J. Rodriguez Cortes <[email protected]>

References

Baddeley, A., Rubak, E., Turner, R. (2015). Spatial Point Patterns: Methodology and Applications with R. CRC Press, Boca Raton.

Chiu, S. N., Stoyan, D., Kendall, W. S., and Mecke, J. (2013). Stochastic Geometry and its Applications. John Wiley & Sons.

Gabriel, E., Rowlingson, B., Diggle P J. (2013) stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software 53, 1-29.

Illian, J B., Penttinen, A., Stoyan, H. and Stoyan, D. (2008). Statistical Analysis and Modelling of Spatial Point Patterns. John Wiley and Sons, London.

Stoyan, D., Rodriguez-Cortes, F. J., Mateu, J., and Gille, W. (2017). Mark variograms for spatio-temporal point processes. Spatial Statistics. 20, 125-147.

Examples

# Ellipsoid
Xe <- stdcpp(lambp=20,a=0.5,b=0.09,c=0.07,mu=100)
plot(Xe$xyt)

# Spatio-temporal 3D scatter plot
par(mfrow=c(1,1))
plot(Xe$xyt,type="scatter")

# Balls
Xb <- stdcpp(lambp=20,a=0.07,b=0.07,c=0.07,mu=100)
plot(Xb$xyt)


# Spatio-temporal 3D scatter plot
par(mfrow=c(1,1))
plot(Xb$xyt,type="mark",style="elegant")

# Northcumbria
data(northcumbria)
Northcumbria <- northcumbria/1000
X <- stdcpp(lambp=0.00004,a=10,b=10,c=10,mu=120,
s.region=Northcumbria,t.region=c(0,200))
plot(X$xyt,s.region=Northcumbria, cex=0.5)

# Spatio-temporal 3D scatter plot
par(mfrow=c(1,1))
plot(X$xyt,type="scatter",theta=45,phi=30,cex=0.1,
ticktype="detailed",col="black",style="elegant")

Spatio-temporal hot-spots cluster point process model

Description

Generate a realisation of the hot-spots cluster process in a region S×TS\times T.

Usage

sthpcpp(lambp, r, mu, s.region, t.region)

Arguments

s.region

Two-column matrix specifying polygonal region containing all data locations.If s.region is missing, the unit square is considered.

t.region

Vector containing the minimum and maximum values of the time interval. If t.region is missing, the interval [0,1][0,1] is considered.

lambp

Intensity of the Poisson process of cluster centres. A single positive number, a function, or a pixel image.

r

Radius parameter of the clusters.

mu

Average number of daughter per parent (a single positive number) or reference intensity for the cluster points (a function or a pixel image).

Details

This function generates a realisation of spatio-temporal cluster process, which can be considered as generalisation of the classical Matern cluster process, inside the spatio-temporal window.

Consider a Poisson point process in the plane with intensity λp\lambda_{p} as cluster centres for all times 'parent', as well as a infinite cylinder of radius RR around of each Poisson point, orthogonal to the plane. The scatter uniformly in all cylinders of all points which are of the form (x,y,z)(x,y,z), the number of points in each cluster being random with a Poisson (μ\mu) distribution. The resulting point pattern is a spatio-temporal cluster point process with t=zt=z. This point process has intensity λp×μ\lambda_{p}\times\mu.

Value

The simulated spatio-temporal point pattern.

Author(s)

Francisco J. Rodriguez Cortes <[email protected]>

References

Baddeley, A., Rubak, E., Turner, R. (2015). Spatial Point Patterns: Methodology and Applications with R. CRC Press, Boca Raton.

Chiu, S. N., Stoyan, D., Kendall, W. S., and Mecke, J. (2013). Stochastic Geometry and its Applications. John Wiley & Sons.

Gabriel, E., Rowlingson, B., Diggle P J. (2013) stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software 53, 1-29.

Illian, J B., Penttinen, A., Stoyan, H. and Stoyan, D. (2008). Statistical Analysis and Modelling of Spatial Point Patterns. John Wiley and Sons, London.

Stoyan, D., Rodriguez-Cortes, F. J., Mateu, J., and Gille, W. (2017). Mark variograms for spatio-temporal point processes. Spatial Statistics. 20, 125-147.

Examples

# First example
X <- sthpcpp(lambp=20, r=0.05, mu=100)
plot(X$xyt)

# Spatio-temporal 3D scatter plot
par(mfrow=c(1,1))
plot(X$xyt,type="scatter")

## Spatio-temporal hot-spots cluster point process model
data(northcumbria)
Northcumbria <- northcumbria/1000
Xo <- sthpcpp(lambp=0.0035, r=5, mu=200,
s.region=Northcumbria, t.region=c(28,198))
plot(Xo$xyt,s.region=Northcumbria)

# Spatio-temporal 3D scatter plot
par(mfrow=c(1,1))
plot(Xo$xyt,type="scatter",style="elegant",theta=45,phi=30,cex=0.05,
ticktype="detailed",col="black")

Estimation of the Space-Time Inhomogeneous K-function

Description

Compute an estimate of the Space-Time Inhomogeneous K-function.

Usage

STIKhat(xyt, s.region, t.region, dist, times, lambda, 
correction="isotropic", infectious=FALSE)

Arguments

xyt

Coordinates and times (x,y,t)(x,y,t) of the point pattern.

s.region

Two-column matrix specifying polygonal region containing all data locations. If s.region is missing, the bounding box of xyt[,1:2] is considered.

t.region

Vector containing the minimum and maximum values of the time interval. If t.region is missing, the range of xyt[,3] is considered.

dist

Vector of distances uu at which K(u,v)K(u,v) is computed. If missing, the maximum of dist is given by min(Sx,Sy)/4\min(S_x,S_y)/4, where SxS_x and SyS_y represent the maximum width and height of the bounding box of s.region.

times

Vector of times vv at which K(u,v)K(u,v) is computed. If missing, the maximum of times is given by (TmaxTmin)/4(T_{\max} - T_{\min})/4, where TminT_{\min} and TmaxT_{\max} are the minimum and maximum of the time interval TT.

lambda

Vector of values of the space-time intensity function evaluated at the points (x,y,t)(x,y,t) in S×TS\times T. If lambda is missing, the estimate of the space-time K-function is computed as for the homogeneous case (Diggle et al., 1995), i.e. considering n/S×Tn/|S \times T| as an estimate of the space-time intensity.

correction

A character vector specifying the edge correction(s) to be applied among "isotropic", "border", "modified.border", "translate" and "none" (see Details). The default is "isotropic".

infectious

Logical value. If TRUE, only future events are considered and the isotropic edge correction method is used. See Details.

Details

Gabriel (2014) proposes the following unbiased estimator for the STIK-function, based on data giving the locations of events xi:i=1,,nx_i: i=1,\ldots,n on a spatio-temporal region S×TS\times T, where SS is an arbitrary polygon and TT is a time interval:

K^(u,v)=i=1nji1wij1λ(xi)λ(xj)1{sisju ; titjv},\widehat{K}(u,v)=\sum_{i=1}^{n}\sum_{j\neq i}\frac{1}{w_{ij}}\frac{1}{\lambda(x_i)\lambda(x_j)}\mathbf{1}_{\lbrace \|s_i - s_j\| \leq u \ ; \ |t_i - t_j| \leq v \rbrace},

where λ(xi)\lambda(x_i) is the intensity at xi=(si,ti)x_i = (s_i,t_i) and wijw_{ij} is an edge correction factor to deal with spatial-temporal edge effects. The edge correction methods implemented are:

isotropic: wij=S×Twij(t)wij(s)w_{ij} = |S \times T| w_{ij}^{(t)} w_{ij}^{(s)}, where the temporal edge correction factor wij(t)=1w_{ij}^{(t)} = 1 if both ends of the interval of length 2titj2 |t_i - t_j| centred at tit_i lie within TT and wij(t)=1/2w_{ij}^{(t)}=1/2 otherwise and wij(s)w_{ij}^{(s)} is the proportion of the circumference of a circle centred at the location sis_i with radius sisj\|s_i -s_j\| lying in SS (also called Ripley's edge correction factor).

border: wij=j=1n1{d(sj,S)>u ; d(tj,T)>v}/λ(xj)1{d(si,S)>u ; d(ti,T)>v}w_{ij}=\frac{\sum_{j=1}^{n}\mathbf{1}\lbrace d(s_j,S)>u \ ; \ d(t_j,T) >v\rbrace/\lambda(x_j)}{\mathbf{1}_{\lbrace d(s_i,S) > u \ ; \ d(t_i,T) >v \rbrace}}, where d(si,S)d(s_i,S) denotes the distance between sis_i and the boundary of SS and d(ti,T)d(t_i,T) the distance between tit_i and the boundary of TT.

modified.border: wij=Su×Tv1{d(si,S)>u ; d(ti,T)>v}w_{ij} = \frac{|S_{\ominus u}|\times|T_{\ominus v}|}{\mathbf{1}_{\lbrace d(s_i,S) > u \ ; \ d(t_i,T) >v \rbrace}}, where SuS_{\ominus u} and TvT_{\ominus v} are the eroded spatial and temporal region respectively, obtained by trimming off a margin of width uu and vv from the border of the original region.

translate: wij=SSsisj×TTtitjw_{ij} =|S \cap S_{s_i-s_j}| \times |T \cap T_{t_i-t_j}|, where SsisjS_{s_i-s_j} and TtitjT_{t_i-t_j} are the translated spatial and temporal regions.

none: No edge correction is performed and wij=S×Tw_{ij}=|S \times T|.

If parameter infectious = TRUE, ony future events are considered and the estimator is, using an isotropic edge correction factor (Gabriel and Diggle, 2009):

K^(u,v)=1S×Tnnvi=1nvj=1;j>inv1wij1λ(xi)λ(xj)1{uiju}1{tjtiv}.\widehat{K}(u,v)=\frac{1}{|S\times T|}\frac{n}{n_v}\sum_{i=1}^{n_v}\sum_{j=1; j > i}^{n_v} \frac{1}{w_{ij}} \frac{1}{\lambda(x_i) \lambda(x_j)}\mathbf{1}_{\left\lbrace u_{ij} \leq u\right\rbrace}\mathbf{1}_{\left\lbrace t_j - t_i \leq v \right\rbrace}.

In this equation, the points xi=(si,ti)x_i=(s_i, t_i) are ordered so that ti<ti+1t_i < t_{i+1}, with ties due to round-off error broken by randomly unrounding if necessary. To deal with temporal edge-effects, for each vv, nvn_v denotes the number of events for which tiT1vt_i \leq T_1 -v, with T=[T0,T1]T=[T_0,T_1]. To deal with spatial edge-effects, we use Ripley's method.

If lambda is missing in argument, STIKhat computes an estimate of the space-time (homogeneous) K-function:

K^(u,v)=S×Tnv(n1)i=1nvj=1;j>inv1wij1{uiju}1{tjtiv}\widehat{K}(u,v)=\frac{|S\times T|}{n_v(n-1)} \sum_{i=1}^{n_v}\sum_{j=1;j>i}^{n_v}\frac{1}{w_{ij}}\mathbf{1}_{\lbrace u_{ij}\leq u \rbrace}\mathbf{1}_{\lbrace t_j - t_i \leq v \rbrace}

Value

A list containing:

Khat

ndist x ntimes matrix containing values of K^ST(u,v).\hat{K}_{ST}(u,v)..

Ktheo

ndist x ntimes matrix containing theoretical values for a Poisson process; πu2v\pi u^2 v for KK and 2πu2v2 \pi u^2 v for KK^*.

dist, times, infectious

Parameters passed in argument.

correction

The name(s) of the edge correction method(s) passed in argument.

Author(s)

Edith Gabriel <[email protected]>

References

Baddeley A., Moller J. and Waagepetersen R. (2000). Non- and semi-parametric estimation of interaction in inhomogeneous point patterns. Statistica Neerlandica, 54, 329–350.

Baddeley, A., Rubak, E., Turner, R., (2015). Spatial Point Patterns: Methodology and Applications with R. CRC Press, Boca Raton.

Diggle P. , Chedwynd A., Haggkvist R. and Morris S. (1995). Second-order analysis of space-time clustering. Statistical Methods in Medical Research, 4, 124–136.

Gabriel E., Diggle P. (2009). Second-order analysis of inhomogeneous spatio-temporal point process data. Statistica Neerlandica, 63, 43–51.

Gabriel E., Rowlingson B., Diggle P. (2013). stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software, 53(2), 1–29.

Gabriel E. (2014). Estimating second-order characteristics of inhomogeneous spatio-temporal point processes: influence of edge correction methods and intensity estimates. Methodology and computing in Applied Probabillity, 16(2), 411–431.

Examples

# First example

data(fmd)
data(northcumbria)
FMD<-as.3dpoints(fmd[,1]/1000,fmd[,2]/1000,fmd[,3])
Northcumbria=northcumbria/1000

# estimation of the temporal intensity
Mt<-density(FMD[,3],n=1000)
mut<-Mt$y[findInterval(FMD[,3],Mt$x)]*dim(FMD)[1]

# estimation of the spatial intensity
h<-mse2d(as.points(FMD[,1:2]), Northcumbria, nsmse=50, range=4)
h<-h$h[which.min(h$mse)]
Ms<-kernel2d(as.points(FMD[,1:2]), Northcumbria, h, nx=5000, ny=5000)
atx<-findInterval(x=FMD[,1],vec=Ms$x)
aty<-findInterval(x=FMD[,2],vec=Ms$y)
mhat<-NULL
for(i in 1:length(atx)) mhat<-c(mhat,Ms$z[atx[i],aty[i]])

# estimation of the STIK function
u <- seq(0,10,by=1)
v <- seq(0,15,by=1)
stik1 <- STIKhat(xyt=FMD, s.region=northcumbria/1000,t.region=c(1,200), 
lambda=mhat*mut/dim(FMD)[1], dist=u, times=v, infectious=TRUE)

# plotting the estimation
plotK(stik1)
plotK(stik1,type="persp",theta=-65,phi=35)
 
# Second example

xyt=rpp(lambda=200)
stik2=STIKhat(xyt$xyt,dist=seq(0,0.16,by=0.02),
times=seq(0,0.16,by=0.02),correction=c("border","translate"))
plotK(stik2,type="contour",legend=TRUE,which="translate")

Space-Time Point Pattern simulation, visualisation and analysis

Description

This package provides models of spatio-temporal point processes in a region S×TS\times T and statistical tools for analysing global and local second-order properties of such processes. It also includes static and dynamic (2D and 3D) plots. stpp is the first dedicated unified computational environment in the area of spatio-temporal point processes.

The stpp package depends upon some other packages:

splancs: spatial and space-time point pattern analysis

rgl: interactive 3D plotting of densities and surfaces

rpanel: simple interactive controls for R using tcltk package

KernSmooth: functions for kernel smoothing for Wand & Jones (1995)

plot3D: Tools for plotting 3-D and 2-D data

ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics

Details

stpp is a package for simulating, analysing and visualising patterns of points in space and time.

Following is a summary of the main functions and the dataset in the stpp package.

To visualise a spatio-temporal point pattern

  • animation: space-time data animation.

  • as.3dpoints: create data in spatio-temporal point format.

  • plot.stpp: plot spatio-temporal point object. Either a two-panels plot showing spatial locations and cumulative times, or a one-panel plot showing spatial locations with times treated as a quantitative mark attached to each location.

  • stan: 3D space-time animation.

To simulate spatio-temporal point patterns

  • rinfec: simulate an infection point process,

  • rinter: simulate an interaction (inhibition or contagious) point process,

  • rlgcp: simulate a log-Gaussian Cox point process,

  • rpcp: simulate a Poisson cluster point process,

  • rpp: simulate a Poisson point process,

  • stdcpp: simulate a double-cluster point process,

  • sthpcpp: simulate a hot-spot point process.

To analyse spatio-temporal point patterns

  • PCFhat: space-time inhomogeneous pair correlation function,

  • STIKhat: space-time inhomogeneous K-function,

  • ASTIKhat: Anisotropic space-time inhomogeneous K-function,

  • LISTAhat: space-time inhomogeneous pair correlation LISTA funcrions.

  • KLISTAhat: space-time inhomogeneous K LISTA functions.

  • gsp: Spatial mark variogram function.

  • gte: Temporal mark variogram function.

  • kmr: Spatial r-mark function

  • kmt: Temporal t-mark function.

  • kmmr: Spatial mark correlation functionn.

  • kmmt: Temporal mark correlation function.

Dataset

fmd: 2001 food-and-mouth epidemic in north Cumbria (UK).

Author(s)

Edith Gabriel <[email protected]>, Peter J. Diggle, Barry Rowlingson and Francisco J. Rodriguez-Cortes

References

Baddeley, A., Rubak, E., Turner, R. (2015). Spatial Point Patterns: Methodology and Applications with R. CRC Press, Boca Raton.

Chan, G. and Wood A. (1997). An algorithm for simulating stationary Gaussian random fields. Applied Statistics, Algorithm Section, 46, 171–181.

Chan, G. and Wood A. (1999). Simulation of stationary Gaussian vector fields. Statistics and Computing, 9, 265–268.

Diggle P. , Chedwynd A., Haggkvist R. and Morris S. (1995). Second-order analysis of space-time clustering. Statistical Methods in Medical Research, 4, 124–136.

Diggle, P.J., 2013. Statistical Analysis of Spatial and Spatio-Temporal Point Patterns. CRC Press, Boca Raton.

Gabriel E. (2014). Estimating second-order characteristics of inhomogeneous spatio-temporal point processes: influence ofedge correction methods and intensity estimates. Methodology and computing in Applied Probabillity, 16(1).

Gabriel E., Diggle P. (2009). Second-order analysis of inhomogeneous spatio-temporal point process data. Statistica Neerlandica, 63, 43–51.

Gabriel E., Rowlingson B., Diggle P. (2013). stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software, 53(2), 1–29.

Gneiting T. (2002). Nonseparable, stationary covariance functions for space-time data. Journal of the American Statistical Association, 97, 590–600.

Gonzalez, J. A., Rodriguez-Cortes, F. J., Cronie, O. and Mateu, J. (2016). Spatio-temporal point process statistics: a review. Spatial Statiscts, 18, 505–544.

Siino, M., Rodriguez-Cortes, F. J., Mateu, J. and Adelfio, G. (2017). Testing for local structure in spatio-temporal point pattern data. Environmetrics. DOI: 10.1002/env.2463.

Stoyan, D., Rodriguez-Cortes, F. J., Mateu, J., and Gille, W. (2017). Mark variograms for spatio-temporal point processes. Spatial Statistics. 20, 125-147.