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
str(lansing)
## List of 6
## $ window :List of 4
## ..$ type : chr "rectangle"
## ..$ xrange: num [1:2] 0 1
## ..$ yrange: num [1:2] 0 1
## ..$ units :List of 3
## .. ..$ singular : chr "foot"
## .. ..$ plural : chr "feet"
## .. ..$ multiplier: num 924
## .. ..- attr(*, "class")= chr "unitname"
## ..- attr(*, "class")= chr "owin"
## $ n : int 2251
## $ x : num [1:2251] 0.078 0.076 0.051 0.015 0.03 0.102 0.135 0.121 0.04 0.065 ...
## $ y : num [1:2251] 0.091 0.266 0.225 0.366 0.426 0.474 0.498 0.489 0.596 0.608 ...
## $ markformat: chr "vector"
## $ marks : Factor w/ 6 levels "blackoak","hickory",..: 1 1 1 1 1 1 1 1 1 1 ...
## - attr(*, "class")= chr "ppp"
names(lansing)
## [1] "window" "n" "x" "y" "markformat"
## [6] "marks"
mytest <- quadrat.test(ants)
## Warning: Some expected counts are small; chi^2 approximation may be inaccurate
plot(mytest)
summary(ants)
## Marked planar point pattern: 97 points
## Average intensity 0.0002261486 points per square unit (one unit = 0.5 feet)
##
## Coordinates are integers
## i.e. rounded to the nearest unit (one unit = 0.5 feet)
##
## Multitype:
## frequency proportion intensity
## Cataglyphis 29 0.2989691 6.761144e-05
## Messor 68 0.7010309 1.585372e-04
##
## Window: polygonal boundary
## single connected closed polygon with 11 vertices
## enclosing rectangle: [-25, 803] x [-49, 717] units
## (828 x 766 units)
## Window area = 428922 square units
## Unit of length: 0.5 feet
## Fraction of frame area: 0.676
str(ants)
## List of 6
## $ window :List of 5
## ..$ type : chr "polygonal"
## ..$ xrange: int [1:2] -25 803
## ..$ yrange: int [1:2] -49 717
## ..$ bdry :List of 1
## .. ..$ :List of 2
## .. .. ..$ x: num [1:11] 471 803 803 600 414 368 29 0 -25 -25 ...
## .. .. ..$ y: num [1:11] -21 250 400 625 699 699 500 442 300 200 ...
## ..$ units :List of 3
## .. ..$ singular : chr "foot"
## .. ..$ plural : chr "feet"
## .. ..$ multiplier: num 0.5
## .. ..- attr(*, "class")= chr "unitname"
## ..- attr(*, "class")= chr "owin"
## $ n : int 97
## $ x : int [1:97] 348 431 264 373 466 148 143 227 348 552 ...
## $ y : int [1:97] 673 663 604 610 607 562 525 533 570 551 ...
## $ markformat: chr "vector"
## $ marks : Factor w/ 2 levels "Cataglyphis",..: 2 2 2 2 2 2 2 2 2 2 ...
## - attr(*, "class")= chr "ppp"
names(ants)
## [1] "window" "n" "x" "y" "markformat"
## [6] "marks"
# 1. What does the ants data consist of and how many points are there?
# 2. Is it marked, and, if so, what do the marks represent?
# 3. Based on the Chi2 test, would you accept or reject Ho?
Answer 1: The ants data consists of a multi-type point pattern spread throughout 428922 square units. There are two species, Cataglyphis and Messor and 97 points in the dataset. Answer 2: yes, nominally marked, representing Cataglyphis and Messor Answer 3: p-value = 0.542, so I would (barely) accept Ho
#make a histogram of the residuals
hist(mytest$residuals)
#conduct Chi-square tests for each species of ant separately. Report and interpret P-values.
quadrat.test(split(ants)$Cataglyphis)
## Warning: Some expected counts are small; chi^2 approximation may be inaccurate
##
## Chi-squared test of CSR using quadrat counts
##
## data: split(ants)$Cataglyphis
## X2 = 33.133, df = 23, p-value = 0.1575
## alternative hypothesis: two.sided
##
## Quadrats: 24 tiles (irregular windows)
quadrat.test(split(ants)$Messor)
## Warning: Some expected counts are small; chi^2 approximation may be inaccurate
##
## Chi-squared test of CSR using quadrat counts
##
## data: split(ants)$Messor
## X2 = 15.153, df = 23, p-value = 0.2219
## alternative hypothesis: two.sided
##
## Quadrats: 24 tiles (irregular windows)
Answer: Cataglyphis p-value = 0.1575. This is less than 0.5 so the Ho is rejected, and there is a low chance that the observed point pattern for the ant species is random. Messor p-value = 0.2219. This is also less than 0.5 so the Ho is rejected, and there is a low chance that the observed point pattern for the ant species is random.
#perform analysis for ants and plot result. What would you conclude from this result?
gest <- Gest(ants)
plot(gest)
Answer: From this result I would conclude that the data is not very
spatially random when compared to the hypothetical function, and there
is a fair amount of indicated spatial clumping (under-dispersion) with
the data under the confidence envelope, and a small amount of regularity
(over-dispersion) towards the end with the data over the confidence
envelope.
##MULTI-TYPE AND BIVARIATE POINT PATTERN ANALYSIS
envelope(lansing, Gcross, nsim = 99, i = 'maple', j = 'hickory')|> plot()
## Generating 99 simulations of CSR ...
## 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.
envelope(lansing, Kcross, nsim = 99, i = 'maple', j = 'hickory')|> plot()
## Generating 99 simulations of CSR ...
## 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.
envelope(lansing, pcfcross, nsim = 99, i = 'maple', j = 'hickory')|> plot()
## Generating 99 simulations of CSR ...
## 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.
#run above code and interpret results. What do these three graphs tell you? Do they all give a consistent message?
Answer: Gcross Function- The observed curve is below the theoretical curve, meaning that there is potential cross-type repulsion, meaning that the maple points are further away from the hickory points than would be expected if they were fully independent. Kcross Function- The observed curve is below the theoretical curve, suggesting that the hickory points are on average more dispersed from maple points than they would be by chance, meaning there is potentially a negative spatial association between the two species. pcfcross Function- The observed curve is less than 1 (gij(r) < 1), meaning that maple points and hickory points are likely repelling each other at distance r. All three of these outputs provide a consistent message: that maple and hickory points seem to have a negative, or adverse, spatial relationship.
#modify this for the ants data to evaluate whether ant nests of the two different species are random, over, or under-dispersed. Interpret the result
envelope(ants, Gcross, nsim = 99, i = 'Cataglyphis', j = 'Messor')|> plot()
## Generating 99 simulations of CSR ...
## 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.
envelope(ants, Kcross, nsim = 99, i = 'Cataglyphis', j = 'Messor')|> plot()
## Generating 99 simulations of CSR ...
## 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.
envelope(ants, pcfcross, nsim = 99, i = 'Cataglyphis', j = 'Messor')|> plot()
## Generating 99 simulations of CSR ...
## 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.
Answer: Gcross: the observed curve is above the theoretical curve
meaning that Cataglyphis ants are, on average, closer to Messor ants
than would be expected under the null hypothesis of independence,
suggesting a cross-type attraction. Kcross: the observed curve is close
to the theoretical curve, meaning that the Messor ants and Cataglyphis
ants are spatially independent of each other. pcfcross: the observed
curve is close to 1 (gij(r) = 1) meaning that the Messor and Cataglyphis
ants are independent from one another at distance r. From these three
results it seems that the two ant species are randomly dispersed or
potentially under-dispersed if following the results of the Gcross
function.
E <- envelope(longleaf, markcorr, nsim = 99)
## Generating 99 simulations of CSR ...
## 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(E)
# 9. Does there appear to be a deviation from the null expectation? Is so, at what distances?
# 10. Does the deviation suggest positive or negative association?
# 11. What does this mean vis a vis the question of whether trees tend to be near other trees of similar size, or whether they tend to be near trees of different sizes?
Answer 9: There is a deviation from the null expectation, especially from 0 to 10 meters Answer 10: The deviation suggests a negative association Answer 11: This means that the trees tend to be found close to trees of different diameters.
#perform a similar analysis with the anemones dataset and interpret the resulting output. What does this tell you about the relationships between distance from nearest neighbors and size in sea-anemones? Construct a hypothesis that would explain the relationship i.e. what might lead to a pattern like this?
E2 <- envelope(anemones, markcorr, nsim = 99)
## Generating 99 simulations of CSR ...
## 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(E2)
Answer: The relationship between nearest neighbors and size is similar
to the longleaf data set, there is a deviation from the null expectation
particularly between 0 and 10 r, suggesting a negative association
meaning that anemones of different sizes tend to be found near each
other. A potential hypotheses that might lead to a pattern like this is
if larger anemones prey on smaller anemones (since they are carnivores
it does happen), which would encourage the mixing of sizes.