[R] about"Riply's K function"and "envelope"
Adrian Baddeley
adrian at maths.uwa.edu.au
Thu Mar 2 09:57:40 CET 2006
Zhang Jian writes:
> I did Riply's K function and envelope in the package "SPATSTAT". When the
> species number is less, it can work well and it is quickly. But when the
> species number is more(example:2000), it told me"memory limit".
If you have a query about a specific package, please ask the
package maintainer. (In the case of `spatstat', that is me.)
The help page
help(envelope)
explains that the default action when you type `envelope(X))'
is to calculate the K functions using Kest().
help(Kest) explains that the spatstat command Kest
calculates multiple estimates of the K function. By default, Kest
calculates estimates of K by three or four different edge corrections
(border, isotropic, translation, ...). Of course this makes the system
run slower.
You can accelerate the calculation by telling Kest to calculate
only one of the estimates. For example:
envelope(X, correction="translate")
runs about 5 times faster than
envelope(X)
This is explained in help(envelope).
For a very large point pattern, Kest runs slowly because it creates
n * n matrices where n is the number of points. An alternative
to Kest is Kest.fft which calculates a smoothed estimate of
the K function using the Fast Fourier Transform. So if you type
envelope(X, Kest.fft, sigma=.....)
this will run 10 to 50 times faster than using Kest.
You have to specify the value of the smoothing parameter sigma
as explained in Kest.fft.
I apologise that the function Kest.fft is not mentioned in the
help page for envelope. We will fix that.
Also please note that there is a bug in spatstat 1.8-6 which causes
some functions to run slower. It is fixed in 1.8-7 which will be
released this week.
regards
Adrian Baddeley
More information about the R-help
mailing list