#Lab Three
plot <- rpoispp(500)
plot(plot)
OR
rpoispp(500) |>
plot()
By including the add = T, you add contour lines that includes a legend to the graph.
The numbers show the number of observations within each cell.
Iteration | Number of Points | Number of Grid Cells | P-values | Interpret P-values |
---|---|---|---|---|
1 | 100 | 400 | 0.4313 | This p-value is not statistically significant meaning we cannot reject the null hypothesis. |
2 | 500 | 25 | 0.6908 | This p-value is not statistically significant meaning we cannot reject the null hypothesis. |
3 | 1000 | 225 | 0.1747 | This p-value is not statistically significant meaning we cannot reject the null hypothesis. |
pp <- rpoispp(function(x,y) {200*x + 200*y})
quadrat.test(pp, nx=8, ny=8)
## Warning: Some expected counts are small; chi^2 approximation may be inaccurate
##
## Chi-squared test of CSR using quadrat counts
##
## data: pp
## X2 = 70.667, df = 63, p-value = 0.474
## alternative hypothesis: two.sided
##
## Quadrats: 8 by 8 grid of tiles
plot(density(pp))
plot(pp, pch = 1, add = TRUE)
After repeating the operation three times my p-values were reported as 0.2683, 0.07029, and 0.005231. The first two p-values suggest no statistical significance whereas the last p-value suggests a statistically significant result.
pp <- rpoispp(function(x,y) {50*x + 50*y})
quadrat.test(pp, nx=8, ny=8)
## Warning: Some expected counts are small; chi^2 approximation may be inaccurate
##
## Chi-squared test of CSR using quadrat counts
##
## data: pp
## X2 = 81.578, df = 63, p-value = 0.1155
## alternative hypothesis: two.sided
##
## Quadrats: 8 by 8 grid of tiles
plot(density(pp))
plot(pp, pch = 1, add = TRUE)
After decreasing the number of grid cells, I found p-values of 0.07638, 0.3313, 0.5563. This affects the interpretation of my p-values because now none of the values are statistically significant.
plot(split(lansing))
plot(split(lansing)$hickory)
density(lansing)
## real-valued pixel image
## 128 x 128 pixel array (ny, nx)
## enclosing rectangle: [0, 1] x [0, 1] units (one unit = 924 feet)
The area for the Lansing data is 924 square feet.
tree <- lansing
tree
## 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)
There are 2251 trees logged in this dataset.
table(tree$marks)
##
## blackoak hickory maple misc redoak whiteoak
## 135 703 514 105 346 448
The most abundant tree in the lansing dataset is hickory while the least abundant is black oak.
plot(split(lansing)$hickory)
plot(split(lansing)$maple)
plot(split(lansing)$blackoak)
Hickory is the most abundant tree with a categorization of clustered. The second most abundant is maple with a categorization of clustered. The least abundant tree was black oak with a clustered categorization as well.
hickory <- subset(lansing, marks == "hickory")
maple <- subset(lansing, marks == "maple")
blackoak <- subset(lansing, marks == "blackoak")
quadrat.test(hickory)
##
## Chi-squared test of CSR using quadrat counts
##
## data: hickory
## X2 = 233.45, df = 24, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 5 by 5 grid of tiles
quadrat.test(maple)
##
## Chi-squared test of CSR using quadrat counts
##
## data: maple
## X2 = 216.93, df = 24, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 5 by 5 grid of tiles
quadrat.test(blackoak)
##
## Chi-squared test of CSR using quadrat counts
##
## data: blackoak
## X2 = 145.56, df = 24, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 5 by 5 grid of tiles
These tests show that there is a significant relationship for all three quadrat analyses.
quadrat.test(split(lansing, nx = 10, ny = 10)$hickory)
##
## Chi-squared test of CSR using quadrat counts
##
## data: split(lansing, nx = 10, ny = 10)$hickory
## X2 = 233.45, df = 24, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 5 by 5 grid of tiles
quadrat.test(split(lansing, nx = 50, ny = 50)$hickory)
##
## Chi-squared test of CSR using quadrat counts
##
## data: split(lansing, nx = 50, ny = 50)$hickory
## X2 = 233.45, df = 24, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 5 by 5 grid of tiles
quadrat.test(split(lansing, nx = 5, ny = 5)$hickory)
##
## Chi-squared test of CSR using quadrat counts
##
## data: split(lansing, nx = 5, ny = 5)$hickory
## X2 = 233.45, df = 24, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 5 by 5 grid of tiles
The p-value for the hickory quadrat analysis at three levels stays the same for every variation in quadrat size. These results are robust to variation.
nncurve <- apply(nndist(rpoispp(500), k=1:500), 2, FUN = mean)
plot(nncurve)
apply(nndist(rpoispp(500), k=1:500), 2, FUN = mean) |>
plot()
```{ r q13} hist(apply(nndist(rpoispp(500), k=1:500), 2, FUN = mean))
plot(apply(nndist(rpoispp(500), k=1:100), 2, FUN = mean), xlab =
“Neighbor Order (k)”, ylab = “Average Nearest Neighbor Distance”, main =
“ANN Values for Different Neighbor Orders”, type = “b”,
pch = 19)
nn_distances <- nndist(split(lansing)$maple, k = 1:100) ann_values
<- colMeans(nn_distances) points(1:length(ann_values), ann_values,
pch = 5)
This graph suggests that maple trees have a lower nearest neighbor distance on average than the average tree.
## Question 15
``` r
plot(apply(nndist(rpoispp(500), k=1:100), 2, FUN = mean),
xlab = "Neighbor Order (k)",
ylab = "Average Nearest Neighbor Distance",
main = "ANN Values for Different Neighbor Orders",
type = "b", # Plot points connected by lines
pch = 19) # Solid circles for points
nn_distances <- nndist(cells, k = 1:42)
ann_values <- colMeans(nn_distances)
points(1:length(ann_values), ann_values,
pch = 5)
This shows that the cells data has a shorter average nearest neighbor distance suggesting that this data is clustered.
plot(Gest(rpoispp(500)))
pp <- rpoispp(function(x,y) {200*x + 200*y})
plot(Gest(pp))
G_env <- envelope(rpoispp(500), 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(G_env)
hickory <- subset(lansing, marks == "hickory")
hickory_g <- envelope(hickory, 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(hickory_g)
Since the observed line is above the predicted confidence band, we can conclude that hickory trees are clumped together.
blackoak <- subset(lansing, marks == "blackoak")
blackoak_g <- envelope(blackoak, 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(blackoak_g)
Since the observed line is above the predicted confidence band, we can conclude that blackoak trees are clumped together.
cells <- cells
cells_g <- envelope(cells, 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(cells_g)
Since the observed line is below the confidence band, we can conclude that the cells data experiences aversion.
longleaf <- longleaf
longleaf_g <- envelope(longleaf, 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(longleaf_g)
Since the observed line is above the confidence band, we can conclude that the longleaf data is clumped.