nis38
nis38

Reputation: 11

Error when simulating Thomas cluster process with Kappa set as a spat image in spatstat (R)

I am trying to simulate Thomas clusters using rThomas function in the spatstat package in R on an inhomogeneous background.

First, I simulate a heterogenous background:

library(spatstat)
Z <- as.im(density(rpoispp(lambda = 14)))
plot(Z)

enter image description here

Then I try to set kappa (intensity of parent points) to my heterogenous background in the rThomas function (as stipulated in the function documentation):

rThomas(scale = 0.1, kappa = Z, mu = 50)

But I get the error:

Error: The window in which the image ‘kappa’ is defined
 is not large enough to contain the dilation of the window ‘win’

This works fine when mu is set to my image, varying the mean offspring per cluster, but I wondered if it was possible to do this with kappa instead.

Many thanks for any help!

Upvotes: 1

Views: 54

Answers (1)

Adrian Baddeley
Adrian Baddeley

Reputation: 2973

The help file for rThomas says:

Note that if kappa is a pixel image, its domain must be larger than the window win. This is because an offspring point inside win could have its parent point lying outside win.

The error message says

The window in which the image kappa is defined is not large enough to contain the dilation of the window win

The parent intensity kappa must be defined on a larger window, if you want a correct simulation of the Thomas process. A bit more detail is given in the help file:

[...] the simulation algorithm first expands the original window win by a distance expand and generates the Poisson process of parent points on this larger window. If kappa is a pixel image, its domain must contain this larger window.

For example

W <- owin()
Wplus <- grow.rectangle(W, 1)
Y <- rpoispp(12, win=Wplus)
Z <- density(Y)
X <- rThomas(Z, win=W, scale=0.1, mu=3)

Upvotes: 1

Related Questions