Skip to content

envelopes to inhomogeneous k-function based on fitted models: with spatstat

2 messages · Raya A. Pruner, Marcelino de la Cruz

#
I have created fitted models for an inhomogeneous point pattern 
using spatstat.  I have used the script below to do so.  I would 
like to create envelopes for the fitted K-function.  However, when 
using the envelope(), it doesn't seem to recognize the lamda 
parameter


##inhomogeneous functions based on top fit covariate model###
lam <- fitted(invert.cord.model, location=nestsF.ppp, 
dataonly=TRUE)
Ki <- Kinhom(nests.ppp, lam, correction="translate")
plot(Ki, sqrt(./pi) - r ~ r, xlab="r(meters)", main="Inhomogeneous 
L-Function- Controlling for Inverts")

g1 <- pcf(Ki, spar=0.9, method="b")
plot(g1, main="Inhomogeneous Pair Correlation Function: Inverts")


Thanks in advance!!
Raya

--
Raya A Pruner - Graduate Student
University of Florida
Department of Wildlife Ecology and Conservation
PO Box 110430
Gainesville, FL 32611-0430
352-214-3262
#
Hi Raya,


You should have provided the code that you tried 
and that "doesn't seem to recognize the lamda parameter".

Anyway, I think that the problem is that you have 
estimated the intensity at the data points only 
(your argument dataonly=TRUE). When computing the 
envelope of the Kinhom function, for each 
simulated pattern you will need an estimate of 
the intensity at the locations of each of the 
simulated points, while your "lam" object has 
only the intensity at the original point locations.

So the easiest way is using a a pixel image 
(object of class "im") assumed to contain the 
values of the intensity function at all locations 
in the window as your lambda.

Try something like this:

lam <- predict.ppm(invert.cord.model, type="trend")

or

lam <- predict.ppm(invert.cord.model, type="trend", covariates= mycovariates)

if your model includes covariates.

Then

Ki.env <- envelope( nests.ppp,  Kinhom, 
lambda=lam, simulate = expression( rpoispp(lam)), correction="translate")

if your model is an heterogeneous poisson or 
using other simulation function (rmh, rMaternI, 
rStrauss, etc) whenever appropirate.


By the way, beware of the  type of prediction 
that you want from your model. By default, 
fitted.ppm  has argument  type="lambda", which 
gives you  the conditional intensity ("lambda") . 
I think you really need the trend, i.e. you should have asked for

lam <- fitted(invert.cord.model, 
location=nestsF.ppp, dataonly=TRUE, type="trend")


Cheers,

Marcelino
At 16:37 23/03/2010, Raya A. Pruner wrote:
________________________________

Marcelino de la Cruz Rot

Departamento de  Biolog?a Vegetal
E.U.T.I. Agr?cola
Universidad Polit?cnica de Madrid
28040-Madrid
Tel.: 91 336 54 35
Fax: 91 336 56 56
marcelino.delacruz at upm.es
_________________________________