[R-sig-Geo] R-sig-Geo Digest, Vol 30, Issue 6
Adrian Baddeley
adrian at maths.uwa.edu.au
Mon Feb 13 03:31:24 CET 2006
Charlotte Reemts writes:
> I am conducting an analysis on disease spread in oak trees. I have the
> locations of symptomatic trees for two years (2004 and 2005) in an
> irregularly-shaped polygon and want to know whether there is attraction or
> repulsion between the two years. The symptomatic trees are clustered within
> a year.
> I used Kcross to calculate the K statistic for my data
First a warning. The usual interpretation of the bivariate K function is
probably not appropriate in this application.
It would not be appropriate to draw conclusions by
comparing the computed Kcross function with the curve K(r) = pi r^2.
The trees do not move from year to year (oder?).
Presumably it is possible for a given tree to be symptomatic
in both years. So the two point patterns may share points in common.
So the usual assumptions for the bivariate K function are false.
> and would like to calculate simulation/confidence envelopes (for
> the univariate data, I used Kenv).
OK, you can of course do a Monte Carlo test (using the envelopes)
> I tried using Kenv.label, but based on my reading of the
> literature, random labelling is not the appropriate test (see
> Goreaud and Pelissier, 2003, Journal of Vegetation Science).
> I cannot use Kenv.tor because my study area is not rectangular.
> Next, I tried using this code:
> kcross.envelope<-envelope(my.data, Kcross, correction="translate", nsim=99)
> The result I get is reasonable, but I would like more information on how
> 'envelope' generates the envelopes (and how it labels the points) and
> whether this is an appropriate test for my data.
envelope() is a function in the library `spatstat'.
help(envelope) explains that the random patterns used to calculate
the envelopes are, **by default**, generated from a Poisson process
with the same intensity as the data point pattern. If the data are
a marked point pattern, this means that the random patterns are
realisations of a Poisson MARKED point process - in other words,
the locations of the points are Poisson (CSR), and their marks are
independent random marks. The random patterns are
randomly-labelled, completely random patterns.
If this default behaviour is not what you want,
then use the argument 'simulate' (of the envelope() function)
to specify how you want the random patterns to be generated.
For example, if you wanted to randomly relabel the existing data pattern
without changing the point locations,
envelope(mydata, Kcross, simulate=expression(rlabel(mydata)))
[Warning: this is in spatstat - be careful of the conflict with the
command 'rlabel' in splancs]
> I cannot use Kenv.tor because my
> study area is not rectangular.
Apparently you want to generate envelopes based on randomly shifting
the existing data pattern (points of each type shifted separately).
The following will work (in spatstat).
rsh <- function(X, d) {
W <- X$window
B <- bounding.box(W)
XB <- X[,B]
Y <- rtoro(XB, radius=d)
Be <- erode.owin(W, d)
Y <- Y[,Be]
return(Y)
}
rad <- 25
W <- rsh(mydata, rad)$window
M <- mydata[,W]
envelope(M, Kcross, simulate=expression(rsh(mydata, rad)))
The new function rsh(X, d) applies random shifts
to the sub-patterns of points of each type, with a maximum shift
distance of d units (change this value 'rad' to a reasonable distance
for your data). It returns a point pattern whose observation window
has been eroded by a distance of d units. Thus, no toroidal wrapping
is needed, and this function works even if X has a non-rectangular window.
The point pattern M is just the restriction of 'mydata' to the
same eroded window, so that comparisons of the Kcross values are
meaningful.
This will become easier in spatstat 1.9.
HTH
Adrian Baddeley
More information about the R-sig-Geo
mailing list