mytest <- quadrat.test(ants)
## Warning: Some expected counts are small; chi^2 approximation may be inaccurate
plot(mytest)
summary(ants)
str(ants)
names(ants)
ants <- ants
The ants data consists of locations of ants, which includes 97 different points.
This data is marked with two levels, Cataglyphis and Messor, which can be assumed to be two different varieties of ants.
mytest
Based on my chi squared, I would fail to reject the null hypothesis since our p-value is 0.5417, much greater than the 0.05 which is required to reject our null hypothesis.
hist(mytest$residuals)
Cata <- quadrat.test(subset(ants,marks == "Cataglyphis"))
## Warning: Some expected counts are small; chi^2 approximation may be inaccurate
Messor <- quadrat.test(subset(ants,marks == "Messor"))
## Warning: Some expected counts are small; chi^2 approximation may be inaccurate
Cata
##
## Chi-squared test of CSR using quadrat counts
##
## data: subset(ants, marks == "Cataglyphis")
## X2 = 33.133, df = 23, p-value = 0.1575
## alternative hypothesis: two.sided
##
## Quadrats: 24 tiles (irregular windows)
Messor
##
## Chi-squared test of CSR using quadrat counts
##
## data: subset(ants, marks == "Messor")
## X2 = 15.153, df = 23, p-value = 0.2219
## alternative hypothesis: two.sided
##
## Quadrats: 24 tiles (irregular windows)
This p-value for the Cataglyphis ant is 0.1575 meaning we cannot reject the null hypothesis and they experience spatial randomness. The p-value for the Messor ant is 0.2219 meaning we also cannot reject the null hypothesis and they also experience spatial randomness.
ants_g <- envelope(ants, Gest, nsim = 95, alpha = 0.05)
## Generating 95 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.
##
## Done.
plot(ants_g)
Since the observed line is below the predicted line we see some regular dispersion. However, since it stays within the confidence band, we can conclude that the ants data is not significant enough to conclude aversion and therefore does display spatial randomness.
envelope(lansing, Gcross, nsim = 99, i = 'maple', j = 'hickory') |> plot()
envelope(lansing, Kcross, nsim = 99, i = 'maple', j = 'hickory') |> plot()
envelope(lansing, pcfcross, nsim = 99, i = 'maple', j = 'hickory') |> plot()
The Gcross graph shows that maple and hickory trees experience a cross-type repulsion. The Kcross graph suggests that maple and hickory trees experience negative spatial associations between the two tree types. The pcfcross shows that maple and hickory trees have a cross type pair correlation less than 1, meaning that maple and hickory trees repel each other. All of these graphs suggest that maple and hickory trees tend to have an aversion to each other and therefore do not grow close together.
envelope(ants, Gcross, nsim = 99, i = 'Cataglyphis', j = 'Messor') |> plot()
envelope(ants, Kcross, nsim = 99, i = 'Cataglyphis', j = 'Messor') |> plot()
envelope(ants, pcfcross, nsim = 99, i = 'Cataglyphis', j = 'Messor') |> plot()
The Gcross graph shows that the two ants are closer together, on average, than if they experienced spatial randomness. This means that the two species are clustering. For the majority of the Kcross graph, the observed line is above the predicted line meaning that the two ant species show slight attraction to on another, although it does stay within the confidence band. The pcfcross graph shows that cross-pair type correlation of the two ants species follows one, meaning they are spatially independent of one another. Even though the first two graphs show the observed line as different from the predicted line, both still fall within the confidence band. Based on all three graphs, the two ant species are spatially independent of each other.
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)
Up until around 12 meters, tree with different sizes deviate from the null hypothesis and tend to be found close together. At around 12 meters and beyond, tree size association becomes less statistically significant as it mostly falls within the confidence band.
This deviation suggests a negative association until 12 meters when there becomes little to no association.
This means that trees of different diameters tend to be found close to on another.
sea <- 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(sea)
Up until around 11 meters, sea anemones location rejects the null hypothesis that there is no relationship between size and location because sea anemones prefer to congregate with different size anemones. After around 11 meters the seem to be little to no correlation between size and location for nearest neighbor distance.