s-news
[Top] [All Lists]

Re: multivariate K function/L function

To: J.Illian@mail1.tay.ac.uk
Subject: Re: multivariate K function/L function
From: Adrian Baddeley <adrian@maths.uwa.edu.au>
Date: Wed, 13 Dec 2000 15:56:46 +0800 (WST)
Cc: s-news@lists.biostat.wustl.edu
Janine Illian writes:

> I am using SPLUS 2000 and would like to analyse some marked point pattern
> data (qualitative marks).
> Have any of you ever used SPLUS to calculate the multivariate K-function/
> L-function in this context?

Yes; this is implemented in `spatstat',
available from
        http://www.maths.uwa.edu.au/~adrian/spatstat.html

Here's a typical worked example. 
The text file "mydata" contains data in table format
with each row containing entries x, y, m representing the (x,y) coordinates
of a point and its mark value m. The window of observation is (say)
the rectangle [0,10] x [0, 5].

        df <- read.table("mydata", header=T)
        df$marks <- factor(df$marks, levels=c("Cold", "Warm", "Hot"))

        pp <- point.pattern(df$x, df$y, c(0,10), c(0,5), marks=df$m)

        plot(pp)

        # univariate K-function
        K <- Kest(pp)
        plot(K$r, K$border, type="l", xlab="r", ylab="K(r)")
        lines(K$r, pi * K$r^2, lty=2)

        # cross K-function
        Khc <- Kcross(pp, "Hot", "Cold")        
        plot(Khc$r, Khc$border, type="l", xlab="r", ylab="Kcross(r)")
        lines(Khc$r, pi * Khc$r^2, lty=2)

The plots can be done more elegantly using plot.formula():
        plot(border ~ r, data=Khc)

The L-function is done by hand:
        plot(sqrt(border/pi) ~ r, data=Khc)

====
Prof Adrian Baddeley, Mathematics & Statistics, University of Western Australia
                <http://maths.uwa.edu.au/~adrian/>

<Prev in Thread] Current Thread [Next in Thread>