Camille Gontier
Camille Gontier

Reputation: 155

How to modify the value of nrank when plotting the envelope for an mppm object in spatstat?

My object model is an mppm object obtained by fitting a model on several independent datasets using the mppm function from the R package spatstat.

Since the envelope function does not accept inputs of type mppm, I used the following code (see question Plot an envelope for an mppm object in spatstat) to study its envelope:

gamma= 1 - 0.95^(1/3)
nsims=round(1/gamma-1)
sims <- simulate(model, nsim=2*nsims)
SIMS <- list()
for(i in 1:nrow(sims)) SIMS[[i]] <- as.solist(sims[i,,drop=TRUE])
Hplus <- cbind(data, hyperframe(Sims=SIMS))

EE <- with(Hplus, envelope(Points, Kcross.inhom,funargs=list("A","A"), nsim=nsims, simulate=Sims,savefuns=TRUE,nrank = 1))

plot(pool(EE), main="A to A interactions")

However, it appears that the value of the parameter nrank has no effect on the final result (same goes, for instance, for the value of nSD). But setting VARIANCE to True does modify the result. How can I choose the rank of the envelope when working with an mppm object ?

Upvotes: 0

Views: 84

Answers (1)

Adrian Baddeley
Adrian Baddeley

Reputation: 1984

This has nothing to do with mppm.

After the second last line is executed, EE is a list of envelope objects . These objects have been correctly computed using the value of nrank that you specified.

The problem is that in the last line, the pool command did not respect the values of nrank used in these envelopes. That is a bug, which I will fix.

In the meantime, the following code will give you what you want:

Epool <- pool(EE, savefuns=TRUE)
Epool2 <- envelope(Epool, nrank=2)

Here the first line gathers all the simulated functions from all the envelopes in EE, and constructs a single, pooled envelope object from them, which also contains all those simulated functions. The second line uses the envelope.envelope to recompute the envelope limits using the saved functions and specifying nrank=2.

Upvotes: 2

Related Questions