0

I would like to ask your help for finding the reason why when I use the function envelope, my arguments are not accepted, but defined "unused arguments". The data I'm using are ppp without marks and I would like to create a L function graph with simulated data and my data. Here the code for my ppp data:

 map2008MLW = ppp(xy2008_BNGppp$x, xy2008_BNGppp$y, window = IoM_polygon_MLWowin)

And then:

L2008 = Lest(map2008MLW,correction="Ripley")
OP = par(mar=c(5,5,4,4))
plot(L2008, . -r ~ r, ylab=expression(hat("L")), xlab = "d (m)"); par(OP)
L2008$iso  = L$iso  - L$r
L2008$theo = L$theo - L$r

Desired number of simulations

n = 9999

Desired p significance level to display

 p  = 0.05

And at this point the envelope function doesnt seem very happy:

    EL2008 = envelope(map2008MLW[W], Lest, nsim=n, rank=(p * (n + 1)))
    Error in envelope(map2008MLW[W], Lest, nsim = n, rank = (p * (n + 1))) : 
  unused arguments (nsim = n, rank = (p * (n + 1)))

It seems a generic error and I am not sure it is caused by the package spatstat. Please, help me in finding a solution to this, as I can't proceed with my analyses.

Thank you very much,

Martina

  • Your example is not reproducible. You refer to data `xy2008_BNGppp` and `IoM_polygon_MLWowin` which we don't have access to. Perhaps you can generate reproducible artificial data which gives the same error? Or upload the data somewhere. You also refer to `L` and `W` which are undefined objects. Could you have another package loaded which also has a function `envelope`? Try using spatstat::envelope to be sure. For hints on how to make a good example so we can help you look here: http://stackoverflow.com/a/5963610/3341769 – Ege Rubak Oct 30 '14 at 19:35
  • Dear Ege, I realized that mine was not a problem due to any errors occurring in the codes, in fact, the same exact codes worked perfectly using R in my colleague's computer. I would like to clarify that the R version was the same (3.1.1) and also the package's one. My IT knowledge was not enough for solving this problem, but at least I managed to run the envelope codes I was keen to. Thanks, – Martina Dec 12 '14 at 17:36
  • According to your error message the most likely thing is that in the R session you were running this you either had attached another package with a function called envelope or had created a function called envelope yourself. I'm glad it is no longer a problem. – Ege Rubak Dec 12 '14 at 20:03

1 Answers1

0

The argument rank should be nrank.

Also the relationship between the significance level and the argument nrank is not correct in the example. For a two-sided test, the significance level is alpha = 2 * nrank/(nsim+1), so nrank= alpha * (nsim+1)/2.

You have chosen a significance level of 0.95 but I assume you mean 0.05. So with nsim=9999 you want nrank=0.05 * 10000/2 = 250 to get a test with significance level 0.05.

Such a large number of simulations (9999) is unnecessary in this kind of application. Monte Carlo tests are valid with small values of nsim. In your example I would normally use nsim=39 and nrank=1.

See Chapter 10 of the spatstat book.

Adrian Baddeley
  • 1,956
  • 1
  • 8
  • 7