Appendix 7: Models of the spatial location of individuals

Appendix 7.1: K-function-based CSR test

To perform a CSR test based on the 1C function we can use the R function envelope from the (spatstat) package. This is a general command to compute simulated confidence envelopes of a summary function according to a given generating point process. By default, if the user does not specify which summary function should be considered and which point process should be simulated, envelope uses the /С-function and the homogeneous Poisson process.

As an example, let us see how to conduct the CSR test for a simulated point pattern dataset. First of all, we generate the point pattern ptsdata within a unit square study area and according to an homogeneous Poisson process with Я = 100:

> library(spatstat)

> set.seed(1234)

> ptsdata <- rpoispp(lambda=100)

> plot(ptsdata)

Secondly, we create the object CSRbands which, among other elements, contains the vectors of the empirical ZC-function computed on ptsdata and the upper and lower confidence envelopes for 999 realizations of a homogeneous Poisson process conditional on the same number of points of ptsdata:

> CSRbands <- envelope(ptsdata, nsim=999)

where the option nsim refers to the desired number of simulated point patterns to be generated.

Finally, the graphical comparison between the empirical /^function and the corresponding upper and lower confidence envelopes can be made through the function plot.envelope, that is:

> plot(CSRbands, fmla=sqrt(./pi) ~ r)

where the option fmla allows to specify which transformation of the function has to be plotted. The string sqrt(./pi) ~ r indicates the Besag’s L transformation.

Appendix 7.2: Point process parameters estimation by the method of minimum contrast

The spatstat functions thomas.estK, matclust.estK and lgcp.estK apply the method of minimum contrast using the ZC-function to estimate the parameters of the Thomas process, the Matern cluster process and the log-Gaussian Cox process, respectively. Their usage is similar and, in its simpler form, only requires to indicate the dataset, as a ppp class object, to be fitted. For example, to fit the three processes to the simulated point pattern data simdat, type:

> library(spatstat)

> plot(simdat)

> fitThomas <- thomas.estK(simdat)

> fitMatern <- matclust.estK(simdat)

> fitLgcp <- lgcp.estK(simdat)

> fitThomas

> fitMatern

> fitLgcp

The resulting objects contain the estimated parameters, the observed values of the empirical ЛГ-function and the values of the theoretical ЛГ-function computed from the fitted model parameters. In particular, fitThomas contains the parameters kappa and scale which represent the intensity of the leader points, p, and the standard deviation a of the followers’ spatial dispersion; fitMatern contains the parameters kappa and scale which represent the intensity of the leader points, p, and the radius R centered on each leader point; fitLgcp contains the parameters var and scale which represent the variance of the underlying Gaussian random field and the scale of the spatial autocorrelation.

In all three cases, the user can specify the value of the constants, q and p, for the contrast criterion. By default, q = 1/4 and p = 2. It is also possible to indicate the interval, rmin and rmax, of the distance values for the contrast criterion. All the three functions have a sensible default.

 
Source
< Prev   CONTENTS   Source   Next >