[R-sig-Geo] Simple Ripley's CRS test for market point patters

Rolf Turner r@turner @end|ng |rom @uck|@nd@@c@nz
Fri Jul 26 02:37:04 CEST 2019


On 25/07/19 12:50 PM, ASANTOS wrote:

> Thanks for your help Marcelino e for the careful explanation Rolf Turner 
> and so sorry about my post script configuration, I expected that I 
> solved that in my new post.
> 
> First my variable area is a marked point (attribute or auxiliary 
> information about my point process - page 7 and not a spatial covariate, 
> effect in the outcome of my experimental area - page 50). Based in this 
> information, my hypophyses is that the *size of ant nests* a cause of 
> ecological intraspecific competition for resources (such as food and 
> territory) *have different patterns of spatial distribution*, for this:
> 
> #Packages
> require(spatstat)
> require(sp)
> 
> # Create some points that represents ant nests
> 
> xp<-c(371278.588,371250.722,371272.618,371328.421,371349.974,
> 371311.95,371296.265,371406.46,371411.551,371329.041,371338.081,
> 371334.182,371333.756,371299.818,371254.374,371193.673,371172.836,
> 371173.803,371153.73,371165.051,371140.417,371168.279,371166.367,
> 371180.575,371132.664,371129.791,371232.919,371208.502,371289.462,
> 371207.595,371219.008,371139.921,371133.215,371061.467,371053.69,
> 371099.897,371108.782,371112.52,371114.241,371176.236,371159.185,
> 371159.291,371158.552,370978.252,371120.03,371116.993)
> 
> yp<-c(8246507.94,8246493.176,8246465.974,8246464.413,8246403.465,
> 8246386.098,8246432.144,8246394.827,8246366.201,8246337.626,
> 8246311.125,8246300.039,8246299.594,8246298.072,8246379.351,
> 8246431.998,8246423.913,8246423.476,8246431.658,8246418.226,
> 8246400.161,8246396.891,8246394.225,8246400.391,8246370.244,
> 8246367.019,8246311.075,8246255.174,8246255.085,8246226.514,
> 8246215.847,8246337.316,8246330.197,8246311.197,8246304.183,
> 8246239.282,8246239.887,8246241.678,8246240.361,8246167.364,
> 8246171.581,8246171.803,8246169.807,8246293.57,8246183.194,8246189.926)
> 
> #Now I have the size of each nest (marked process)
> 
> area<-c(117,30,4,341,15,160,35,280,108,168,63,143,2,48,182,42,
> 88,56,27,156,288,45,49,234,72,270,91,40,304,56,35,4,56.7,9,4.6,
> 105,133,135,23.92,190,12.9,15.2,192.78,104,255,24)
> 
> # Make a countour for the window creation
> W <- convexhull.xy(xp,yp)
> 
> 
> # Class of nests size - large, medium and small
> acat <- cut(area,breaks=c(-Inf,25,55,Inf),right=FALSE, 
> labels=c("s","m","l"))
> 
> #Create a ppp object
> 
> syn.ppp <- ppp(x=xp,y=yp,window=W, marks=acat)
> 
> # Test intensity hypothesis
> 
> f1 <- ppm(syn.ppp) # Same (constant) intensity for each area category.
> f2 <- ppm(syn.ppp ~ marks) # Allows different (constant) intensity for 
> each area category.
> anova(f1,f2,test="Chi")
> 
> #0.002015 ** OK, the hypothesis that the intensities are the same was 
> reject, but intensities is not the question.
> 
> Based in my initial hypothesis, I've like to show envelopes and observed 
> values of the use of some function for the three point patters (large, 
> medium and small ant nest size)under CSR. And for this I try to:
> 
> kS<-envelope(syn.ppp[syn.ppp$acat=="s"], nsim=99,fun=Kest)
> 
> plot(kS,lwd=list(3,1,1,1), main="")
> 
> kM<-envelope(syn.ppp[syn.ppp$acat=="m"], nsim=99,fun=Kest)
> 
> plot(kM,lwd=list(3,1,1,1), main="")
> 
> kL<-envelope(syn.ppp[syn.ppp$acat=="l"], nsim=99,fun=Kest)
> 
> plot(kL,lwd=list(3,1,1,1), main="")
> 
> But doesn't work yet. My approach now sounds correct?
> 
> Thanks in advanced,

The formatting of your latest email was a great improvement and is now 
admirably legible.

I am still not completely clear what your research question is, or what 
hypotheses you wish to test.

Let me preface my remarks by saying that I have so far gone along with 
your inclination to convert the numeric marks (area) of your pattern to 
categorical (small, medium, large) marks.  I believe that this may be a
suboptimal approach.  (As someone said in an old post to R-help, on an 
entirely  different topic, 'There is a reason that the speedometer in 
your car doesn't just read "slow" and "fast".' :-) )

On the other hand there is not a lot on offer in the way of techniques 
for handling numeric marks, so the "discretisation" approach may be the 
best that one can do.

Now to proceed with trying to answer your question(s).  You say:

> my hypophyses is that the size of ant nests a cause of ecological
> intraspecific competition for resources (such as food and territory)
> have different patterns of spatial distribution

That's a (rather vague) "*alternative*" hypothesis.  The corresponding 
null  hypothesis is that the three categories have the *same* spatial 
distribution.   We reject that null hypothesis, since we reject the 
hypothesis that they have the same intensities.

Now what?

You say:

> Based in my initial hypothesis, I've like to show envelopes and observed
> values of the use of some function for the three point patters (large,
> medium and small ant nest size) under CSR.

This is a bit incoherent and a demonstrates somewhat confused thinking. 
  As the signature file of a frequent poster to R-help says "Tell me 
what you want to do, not how you want to do it."

Perhaps the following will help to clarify.  For a categorical marked 
point pattern (which is what we are currently dealing with) there are 
infinitely many possibilities for the joint distribution of the patterns 
corresponding to the marks.

The simplest of these is CSR (which means that the marks are essentially 
irrelevant).  We have already rejected this hypothesis.

The next simplest is what is designated in [1; p. 584] as "CSRI" 
(complete spatial randomness with independence).   This means that each 
of the patterns is "individually CSR" (Poisson process, constant 
intensity) and that the patterns are independent.

After that, the possibilities explode astronomically --- different 
(non-Poisson) structures for each of the patterns, different dependence 
structures, ....  The sky's the limit.

One "reasonably simple" possibility amongst this plethora of 
possibilities is the multitype Strauss point process model, which could 
be fitted (with some effort) using ppm() and profilepl().

However before we open that can of worms, we can test "CSRI":

fit <- ppm(syn.ppp ~ marks)
set.seed(42)
E <- envelope(fit,savefuns=TRUE)
dclf.test(E)
mad.test(E)

The dclf test gives a p-value of 0.14; the mad test gives a p-value of 
0.18.  Thus there appears to be no evidence against the null hypothesis 
of CSRI.

Therefore "CSRI" would appear to be an adequate/plausible model for 
these data.

There may be more that needs to be done, but this is a start.

I would appreciate comments from Marcelino (and of course from Adrian 
and Ege) especially if any of them notice something incorrect in my advice.

cheers,

Rolf

[1] Spatial Point Patterns: Methodology and Applications with R
1st Edition, Adrian Baddeley, Ege Rubak, Rolf Turner
Chapman and Hall/CRC, 2015

P. S.  You said of your efforts to continue your analysis: "But doesn't 
work yet."  This is a very vague and unhelpful assertion!  One thing 
that is wrong with your efforts is that in,  e.g.:

     kS<-envelope(syn.ppp[syn.ppp$acat=="s"], nsim=99,fun=Kest)

the object syn.ppp has no component named "acat"!!!  (You really need to 
gain some understanding of how R works!)

You *could* say

    kS <- envelope(syn.ppp[syn.ppp$marks=="s"])

or (better)

     kS <- envelope(syn.ppp[marks(syn.ppp)=="s"])

to get the sort of result that you had hoped for.  Note that specifying 
the arguments nsim=99 and fun=Kest, while harmless, is redundant (and 
therefore tends to obfuscate).  These are the *default* values!!!  Read 
the help, and learn to use R efficiently!

R.

-- 
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



More information about the R-sig-Geo mailing list