Steve Markofsky
2008-Mar-04 10:37 UTC
[R] Ripley's K function within envelope--how to change the maximum distance?
Hi--I'm trying to run a Ripley's K analysis on a point pattern within a window of 1 square km. The maximum distance I want to use is the diagonal of the window, around 1400m, run in 50m increments. The function defaults to a 250m maximum--I thought this was simply the way I had plotted it, but when I exported the data there was nothing over 250m. I've looked into seq and ginterval, and I think that seq may be my answer, but I'm not exactly sure how to use it properly within the envelope function. Here's two versions of the code I'm working with: ERip<-envelope(EforRip,fun=Kest,correction=c("Ripley"),nsim=99,rank=1,transform=expression(sqrt(./pi)),global=TRUE) ERip<-envelope(EforRip,fun=Kest,r=seq(0,1400,50),correction=c("Ripley"),nsim=99,rank=1,transform=expression(sqrt(./pi)),global=TRUE) I think I'm missing something obvious, but couldn't find the solution. Thanks very much-- Steve Steve Markofsky Institute of Archaeology University College London Mobile: 07779-789-720 Email: s.markofsky at ucl.ac.uk
adrian at maths.uwa.edu.au
2008-Mar-06 02:20 UTC
[R] Ripley's K function within envelope--how to change the maximum distance?
Steve Markofsky <s.markofsky at ucl.ac.uk> writes:> I'm trying to run a Ripley's K analysis on a point pattern > within a window of 1 square km. > The maximum distance I want to use is the diagonal > of the window, around 1400m, run in 50m increments.You can't estimate K(r) for r equal to the diagonal of the window, as there is no data at this distance. The Ripley isotropic correction is only valid for r values that are less than HALF the diagonal, which would be 707m. Because of the high variability of the estimate when r is large, the usual recommended maximum distance for estimating K(r) is half the length of the shortest side of the rectangle, so that would be 500m. Ripley's own recommendation is to restrict it to one QUARTER of the shortest side length, or 250m. You ask how to do this in the package 'spatstat' in the context of a simulation envelope.> ERip<-envelope(EforRip,fun=Kest,r=seq(0,1400,50),correction=c > ("Ripley"),nsim=99,rank=1,transform=expression(sqrt(./ > pi)),global=TRUE)If you replace 1400 by something smaller, eg 500, then this code should work. (Since you're using the L function, you could also replace 'Kest' by 'Lest' and then remove the 'transform' argument). The result 'ERip' is an fv object (function value table). By default, plot(ERip) will restrict the r values to the recommended range [0,250]. But you can plot them over a larger range by plot(ERip, xlim=c(0,500)). Adrian Baddeley