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

ASANTOS @|ex@ndre@@nto@br @end|ng |rom y@hoo@com@br
Mon Jul 29 23:12:00 CEST 2019


Dr. Rolf Turner,

 ???? Thanks again and your explanations as a personal spatial course for 
me :) You are very clear, but there are some questions yet. First, these 
data set is not artificial, I have real coordinates and area of nests of 
leaf-cutting ants in my example (in my complete data set I have more 
than 3,000 coordinates and areas). The problem of overlap is because we 
represent a ants nests area as a circle (for an easy comprehension and 
modeling), but in the real world this areas was elliptical and some 
times we have an eccentricity close to 1 (in this case I have two nests 
close but not in overlap condition in the field). Based on our comments, 
I used the CSRI test, but first I try to explore more the question about 
intensities and size categories (s, m, and l), for this,could I test 
intensities by pair-wise comparison? For the last, do you have any 
solution for my overlap problem, if my objective is the study of my 
problem as a realization of a Poisson process?

Please see my code below:

#Packages
require(spatstat)
require(sp)

# Create some points that represent 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 contour 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 initial 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") #The test?? rejects the hypothesis that the 
intensities are the same - p =0.002015 **

*#First question, could I test intensities by pair-wise comparison?*

# Small vs medium sizes
acat2<-acat
levels(acat2)
levels(acat2)[1]<-"s_m"
levels(acat2)[2]<-"s_m"
levels(acat2)
syn.ppp2 <- ppp(x=xp,y=yp,window=W, marks=acat2)
f3 <- ppm(syn.ppp2 ~ marks)
f4 <- ppm(syn.ppp2)
anova(f4,f3,test="Chi") #Intensities of small and medium size are the 
same - p=0.237

# Medium vs large sizes
acat3<-acat
levels(acat3)
levels(acat3)[2]<-"m_l"
levels(acat3)[3]<-"m_l"
levels(acat3)
syn.ppp3 <- ppp(x=xp,y=yp,window=W, marks=acat3)
f5 <- ppm(syn.ppp3 ~ marks)
f6 <- ppm(syn.ppp3)
anova(f5,f6,test="Chi") #Intensities of medium and large sizes are the 
different - p=7.827e-05 ***

Finally small and medium sizes has the same intensity but is different 
of large ants size!!! With this condition I will test the CSRI:

*#Now testing CSRI by simulation*

foo <- function(W){
s_m <- runifpoint(length(area<55),win=W)
l <- runifpoint(length(area>=55),win=W)
superimpose(s_m=s_m,l=l)
}
simex <- expression(foo(W))

#and then

set.seed(12)
E <- envelope(syn.ppp2,simulate=simex,nsim=999, savefuns=TRUE)
plot(E)
dtst <- dclf.test(E)
plot(dtst)
mtst <- mad.test(E)
plot(mtst)
# now gives p-value = 0.003 for dtst and p-value = 0.002 for mtst

Thanks in advanced,

Alexandre

-- 
======================================================================
Alexandre dos Santos
Prote????o Florestal
IFMT - Instituto Federal de Educa????o, Ci??ncia e Tecnologia de Mato Grosso
Campus C??ceres
Caixa Postal 244
Avenida dos Ramires, s/n
Bairro: Distrito Industrial
C??ceres - MT                      CEP: 78.200-000
Fone: (+55) 65 99686-6970 (VIVO) (+55) 65 3221-2674 (FIXO)

         alexandre.santos using cas.ifmt.edu.br
Lattes: http://lattes.cnpq.br/1360403201088680
OrcID: orcid.org/0000-0001-8232-6722
Researchgate: www.researchgate.net/profile/Alexandre_Santos10
LinkedIn: br.linkedin.com/in/alexandre-dos-santos-87961635
Mendeley:www.mendeley.com/profiles/alexandre-dos-santos6/
======================================================================

Em 26/07/2019 17:29, Rolf Turner escreveu:
>
> I have realised that there were a couple of oversights in my previous 
> posting on this issue.?? One is a bit subtle; the other is a bit of a 
> blunder on my part.
>
> First the "subtle" one. The test that I proposed for CSRI is a test 
> done using the estimated parameters of the proposed model to generate 
> realisations of data sets under the null hypothesis. Such tests tend 
> to be conservative.?? (See section 10.6.3, p. 388 ff., in [1].)
>
> In the current instance (testing for CSRI) the conservatism can be 
> overcome by simulating data conditional on the numbers of points of 
> each type in the "real" data.?? This can be done here via:
>
> foo <- function(W){
> s <- runifpoint(10,win=W)
> m <- runifpoint(9,win=W)
> l <- runifpoint(27,win=W)
> superimpose(s=s,m=m,l=l)
> }
> simex <- expression(foo(W))
>
> and then
>
> set.seed(42)
> E <- envelope(syn.ppp,simulate=simex,savefuns=TRUE)
> dtst <- dclf.test(E)
> mtst <- mad.test(E)
>
> This gives p-values of 0.06 from the dclf test and 0.09 from the mad 
> test.?? Thus there appears to be some slight evidence against the null 
> hypothesis.?? (Evidence at the 0.10 significance level.)
>
> That this should be so is *OBVIOUS* (!!!) if we turn to the unsubtle 
> point that I overlooked.?? It is clear that the pattern of ants' nests 
> cannot be truly a realisation of a Poisson process since there must be 
> a bit of a "hard core" effect.?? Two ants' nests cannot overlap.?? Thus 
> if we approximate the shape of each nest by a disc, points i and j 
> must be a distance of at least r_i + r_j from each other, where r_i = 
> sqrt(area_i/pi), and similarly for r_j.
>
> However I note that the data provided seem to violate this principle 
> in several instances.?? E.g. points 41 and 42 are a distance of only 
> 0.2460 metres apart but areas 41 and 42 are 12.9 and 15.2 square 
> metres, yielding putative radii of 3.5917 and 3.8987 metres, whence 
> the closest
> these points could possibly be (under the "disc-shaped assumption") is
> 7.4904 metres, far larger than 0.2460.???? So something is a bit out of 
> whack here.?? Perhaps these are made-up ("synthetic") data and the 
> process of making up the data did not take account of the minimum 
> distance constraint.
>
> How to incorporate the "hard core" aspect of your (real?) data into 
> the modelling exercise, and what the impact of it is upon your 
> research question(s), is unclear to me and is likely to be complicated.
>
> cheers,
>
> Rolf
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list