Reputation: 11
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)
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
Reputation: 2973
The help file for rThomas
says:
Note that if
kappa
is a pixel image, its domain must be larger than the windowwin
. This is because an offspring point insidewin
could have its parent point lying outsidewin
.
The error message says
The window in which the image
kappa
is defined is not large enough to contain the dilation of the windowwin
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 distanceexpand
and generates the Poisson process of parent points on this larger window. Ifkappa
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