[R-sig-Geo] memory allocation problem with envelope function in spatstat

Adrian.Baddeley at csiro.au Adrian.Baddeley at csiro.au
Mon May 10 09:09:50 CEST 2010


Erika Mudrak <mudrak at wisc.edu> writes:

! Hi everyone-  I am trying to fit an inhomogenous K function based to 
! a large(ish) dataset.  I have successfully executed this code on data sets 
! with a smaller n. 

! > SPECIES.ppp
! planar point pattern: 1598 points 
! window: rectangle = [564320, 564320] x [228490, 228500] units 
! > lambda=density(SPECIES.ppp)
! > Lin=envelope(SPECIES.ppp,Linhom,nsim=5,simulate=expression(rpoispp(lambda)),
! + correction="border")
! Error: cannot allocate vector of size 244.5 Mb

Memory allocation problems in a point process simulation typically happen when the system is trying to generate a huge number of points.

In this simulation, the expected number of random points in each randomised pattern is equal to the integral of the pixel image 'lambda', which you can evaluate by
     summary(lambda)$integral 
and of course you can also plot(lambda) to see if there is anything strange happening.

Normally the code you have typed above should be OK. If X is a point pattern with 1600 points then the intensity estimate computed by lambda <- density(X) should have an integral approximately equal to 1600 except for edge effects. So the expected number of points in each simulation should be about 1600.

However, there could be a problem here with the shape of the window and/or the configuration of the data points. The printout above says the window is 

! window: rectangle = [564320, 564320] x [228490, 228500] units 

The width of the rectangle appears to be 0; but these coordinates have been rounded to the nearest multiple of 10. Please tell me the window width is not exactly zero!!! 
I would guess that you have a very thin window, with some points that are very close to the boundary. Because of edge effects and various numerical artifacts, this could result in an erroneously large intensity estimate. 

My advice is to make sure that the density estimate 'lambda' is reasonable. Try controlling the smoothing parameter 'sigma' and the pixel size 'eps' until the estimated intensity looks reasonable and the integral summary(lambda)$integral is tolerably close to 1600.

regards 
Adrian Baddeley 
CSIRO Mathematics, Informatics & Statistics
Leeuwin Centre, 65 Brockway Road, Floreat WA 6014, Australia
Tel: 08 9333 6177 | Fax: 08 9333 6121 | Mob: 0410 447 821



More information about the R-sig-Geo mailing list