A marked point pattern in which the marks are a categorical variable is usually called a multitype point pattern. The types are the different values or levels of the mark variable
For reference, here is a list of the standard point pattern datasets that are supplied with the installation of spatstat
name | description | marks | covariates | window |
---|---|---|---|---|
amacrine |
Hughes’ rabbit amacrince cells | 2 types | - | |
anemones |
Uption-Fingleton sea anemones | diameter | - | |
ants |
Harkness-Isham ant nests | 2 species | 2 zones | convex poly |
bei |
Tropical rainforest trees | - | topography | |
betacells |
Wassle et al. cat retinal ganglia | 2 types | - | |
bramblecanes |
Bramble Canes | 3 ages | - | |
cells |
Crick-Ripley biological cells | - | - | |
chorley |
Chorley-South Ribble cancers | case/controls | - | irregular |
copper |
Queensland copper deposits | - | fault lines | |
demopat |
artificial data | 2 types | - | irregular |
finpines |
Finnish Pines | diameter | - | |
hamster |
Aherne’s hamster tumour data | 2 types | - | |
humberside |
Humberside child leukaemia | case/controls | - | irregular |
japanesepines |
Japanese Pines | - | - | |
lansing |
Lansing Woods | 6 species | - | |
longleaf |
Longleaf Pine trees | diameter | - | |
nbfires |
New Brunswick fires | several | - | irregular |
nztrees |
Mark-Esler-Ripley NZ trees | - | - | |
ponderosa |
Getis-Franklin Ponderosa pines | - | - | |
redwood |
Strauss-Ripley redwood saplings | - | - | |
redwoodfull |
Strauss redwood map (full set) | - | 2 zones | |
simdat |
Simulated point patterns | - | - | |
spruces |
Spruce trees in Saxony | diameter | - | |
swedishpines |
Strand-Ripley-Swedish pines | - | - |
help(ants)
ants {spatstat.data}
Description
These data give the spatial locations of nests of two species of ants, Messor wasmanni and Cataglyphis bicolor, recorded by Professor R.D. Harkness at a site in northern Greece, and described in Harkness & Isham (1983). The full dataset (supplied here) has an irregular polygonal boundary, while most analyses have been confined to two rectangular subsets of the pattern (also supplied here).
The harvester ant M. wasmanni collects seeds for food and builds a nest composed mainly of seed husks. C. bicolor is a heat-tolerant desert foraging ant which eats dead insects and other arthropods. Interest focuses on whether there is evidence in the data for intra-species competition between Messor nests (i.e. competition for resources) and for preferential placement of Cataglyphis nests in the vicinity of Messor nests.
The full dataset is displayed in Figure 1 of Harkness & Isham (1983). See Usage below to produce a comparable plot. It comprises 97 nests (68 Messor and 29 Cataglyphis) inside an irregular convex polygonal boundary, together with annotations showing a foot track through the region, the boundary between field and scrub areas inside the region, and indicating the two rectangular subregions A and B used in their analysis.
Rectangular subsets of the data were analysed by Harkness & Isham (1983), Isham (1984), Takacs & Fiksel (1986), S"arkk"a (1993, section 5.3), H"ogmander and S"arkk"a (1999) and Baddeley & Turner (2000). The full dataset (inside its irregular boundary) was first analysed by Baddeley & Turner (2005b).
The dataset ants
is the full point pattern enclosed by the irregular polygonal boundary. The x and y coordinates are eastings (E-W) and northings (N-S) scaled so that 1 unit equals 0.5 feet. This is a multitype point pattern object, each point carrying a mark indicating the ant species (with levels Cataglyphis
and Messor
).
data(ants)
ants
## Marked planar point pattern: 97 points
## Multitype, with levels = Cataglyphis, Messor
## window: polygonal boundary
## enclosing rectangle: [-25, 803] x [-49, 717] units (one unit = 0.5 feet)
plot(ants)
plot(split(ants))
quad1 <- quadratcount(split(ants))
plot(quad1)
Hipotesis:
H0: Titik-titik pada Himpunan \(P_A\) dan \(P_B\) adalah menyebar secara independen
H1: Titik-titik pada Himpunan \(P_A\) dan \(P_B\) adalah menyebar secara tidak independen (Mereka berkorelasi secara spasial antara sesamanya)
\(\chi^2_{hitung} > \chi^2_{tabel}\) maka cukup bukti untuk menolak H0. Artinya, dapat disimpulkan bahwa pada 𝛼 = 5%, sebaran spasial dari kedua species semut tersebut tidak saling bebas.
catag<-quad1[[1]]
mess<-quad1[[2]]
Obs<-matrix(NA,2,2)
rownames(Obs)<-c("A","0")
colnames(Obs)<-c("B","0")
Obs[1,1]<-sum(((catag>0)+(mess>0))==2) #ab
Obs[2,1]<-sum(((catag>0)-(mess>0))==1) #a0
Obs[1,2]<-sum(((catag>0)-(mess>0))==-1) #0b
Obs[2,2]<-sum(((catag>0)+(mess>0))==0) #00
Tes<-chisq.test(Obs)
chisqhitung<-sum((Obs-Tes$expected)^2/Tes$expected)
chistabel<-qchisq(0.05,df=1,lower.tail=F)
p_valuechi<-pchisq(chisqhitung,1,lower.tail=F)
chisq.test(Obs, correct = F)
##
## Pearson's Chi-squared test
##
## data: Obs
## X-squared = 11.2, df = 1, p-value = 0.000818
Kest{spatstat}
Description
Estimates Ripley’s reduced second moment function K(r) from a point pattern in a window of arbitrary shape.
Usage
Kest(X, ..., r=NULL, rmax=NULL, breaks=NULL,
correction=c("border", "isotropic", "Ripley", "translate"),
nlarge=3000, domain=NULL, var.approx=FALSE, ratio=FALSE)`
```
> The estimator Kest **ignores marks**. Its counterparts for multitype point patterns are [Kcross](http://127.0.0.1:16418/library/spatstat/help/Kcross), [Kdot](http://127.0.0.1:16418/library/spatstat/help/Kdot), and for general marked point patterns see [Kmulti](http://127.0.0.1:16418/library/spatstat/help/Kmulti).
#### Ripley’s K estimator for Multitype Point
Function | Description |
---|---|
Kdot | For a multitype point pattern, estimate the multitype K function which counts the expected number of other points of the process within a given distance of a point of type i. |
Kcross | For a multitype point pattern, estimate the multitype K function which counts the expected number of points of type j within a given distance of a point of type i. |
Kmulti | For a marked point pattern, estimate the multitype K function which counts the expected number of points of subset J within a given distance from a typical point in subset I. |
unique(ants$marks)
## [1] Messor Cataglyphis
## Levels: Cataglyphis Messor
Kh <- Kdot(ants, "Messor")
plot(Kh)
diagnostic plot for independence between Messor and other species
f1 <- function(X) { marks(X) == "Messor"}
f2 <- function(X) { marks(X) == "Cataglyphis"}
K <- Kmulti(ants,f1,f2)
plot(K)
K01 <- Kcross(ants, "Messor", "Cataglyphis")
plot(K01)
plot(envelope(ants, Kcross,
i="Messor",
j="Cataglyphis", nsim=99,
fix.n=T, fix.marks=T))
## Generating 99 simulations of CSR with fixed number of points of each type ...
## 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
## 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
## 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99.
##
## Done.
plot(envelope(ants, Kdot,
i="Messor",
nsim=99,
fix.n=T, fix.marks=T))
## Generating 99 simulations of CSR with fixed number of points of each type ...
## 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
## 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
## 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99.
##
## Done.
plot(envelope(ants, Kmulti,
I=f1, J=f2, nsim=99,
fix.n=T, fix.marks=T))
## Generating 99 simulations of CSR with fixed number of points of each type ...
## 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
## 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
## 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99.
##
## Done.
mad.test(ants, Kcross, i="Messor", j="Cataglyphis", nsim=99,
fix.n=T, fix.marks=T)
## Generating 99 simulations of CSR with fixed number of points of each type ...
## 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
## 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
## 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99.
##
## Done.
##
## Maximum absolute deviation test of CSR
## Monte Carlo test based on 99 simulations with fixed number of points
## of each type
## Summary function: "K"["Messor", "Cataglyphis"](r)
## Reference function: theoretical
## Alternative: two.sided
## Interval of distance values: [0, 191.5] units (one unit = 0.5 feet)
## Test statistic: Maximum absolute deviation
## Deviation = observed minus theoretical
##
## data: ants
## mad = 5161, rank = 68, p-value = 0.68
Here is the famous Lansing Woods dataset recording the positions of 2251 trees of 6 different species (hickories, maples, red oaks, white oaks, black oaks and miscellaneous trees).
data(lansing)
lansing
## Marked planar point pattern: 2251 points
## Multitype, with levels = blackoak, hickory, maple, misc, redoak, whiteoak
## window: rectangle = [0, 1] x [0, 1] units (one unit = 924 feet)
summary(lansing)
## Marked planar point pattern: 2251 points
## Average intensity 2251 points per square unit (one unit = 924 feet)
##
## *Pattern contains duplicated points*
##
## Coordinates are given to 3 decimal places
## i.e. rounded to the nearest multiple of 0.001 units (one unit = 924 feet)
##
## Multitype:
## frequency proportion intensity
## blackoak 135 0.05997335 135
## hickory 703 0.31230560 703
## maple 514 0.22834300 514
## misc 105 0.04664594 105
## redoak 346 0.15370950 346
## whiteoak 448 0.19902270 448
##
## Window: rectangle = [0, 1] x [0, 1] units
## Window area = 1 square unit
## Unit of length: 924 feet
plot(lansing)
plot(split(lansing))
plot(density(split(lansing)), ribbon = F)
hick <- split(lansing)$hickory
plot(hick)
plot(quadratcount(split(lansing)))
Kh. <- Kdot(lansing,"hickory")
plot(Kh.)