Question 1
##question 1 - two other ways to do the above function
#rpoispp(500)|>
#plot()
randomplot <- rpoispp(500)
plot(randomplot)

Question 2: It adds the contour lines and points overtop of the
existing density map
Question 3: It shows how many data points are within a grid
cell
Question 4:
# Print results table
print(results)
## Number.of.Points Grid.Cells P.value Interpretation
## 1 555 400 0.7947421 Likely CSR
## 2 495 400 0.7180999 Likely CSR
## 3 490 400 0.4633854 Likely CSR
Question 5:
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 = 101.74, df = 63, p-value = 0.002879
## alternative hypothesis: two.sided
##
## Quadrats: 8 by 8 grid of tiles
#1st operation: p-value = 0.00904 , unlikely
#2nd operation: p-value = 0.02313 , unlikely
#3rd operation: p-value = 0.05535 , likely
Question 6: It does not affect the interpretation of the p-values,
only the possibility of CSR being more or less likely
plot(split(lansing))

plot(split(lansing)$hickory)

Question 7: Area = 924×924 = 853,776 square feet
Question 8: There are 2251 trees in the dataset
npoints(lansing)
## [1] 2251
Question 9: Ignoring misc., the most abundant is hickory and the
least abundant is black oak
table(marks(lansing))
##
## blackoak hickory maple misc redoak whiteoak
## 135 703 514 105 346 448
Question 10: a) The most abundant, hickory, looks dispersed but with
some aggregated areas, and the second most abundant, maple, looks
aggregated. b) The least abundant, black oak, looks to be
aggregated
plot(split(lansing)$hickory)

plot(density(split(lansing)$hickory))

plot(split(lansing)$maple)

plot(density(split(lansing)$maple))

plot(split(lansing)$blackoak)

plot(density(split(lansing)$blackoak))

Question 11: All three tests produced vlaues below 0.05 and so all
three are significant
quadrat.test(Hickory, nx = 8, ny = 8)
##
## Chi-squared test of CSR using quadrat counts
##
## data: Hickory
## X2 = 318.91, df = 63, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 8 by 8 grid of tiles
quadrat.test(Maple, nx = 8, ny = 8)
##
## Chi-squared test of CSR using quadrat counts
##
## data: Maple
## X2 = 352.12, df = 63, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 8 by 8 grid of tiles
quadrat.test(Blackoak, 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: Blackoak
## X2 = 182.16, df = 63, p-value = 3.27e-13
## alternative hypothesis: two.sided
##
## Quadrats: 8 by 8 grid of tiles
Question 12: The result from this shows a spatial pattern with the
Hickory trees being highly structured and likely aggregated
hickory <- split(lansing)$hickory
quadrat.test(hickory, nx = 3, ny = 3)
##
## Chi-squared test of CSR using quadrat counts
##
## data: hickory
## X2 = 163.8, df = 8, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 3 by 3 grid of tiles
quadrat.test(hickory, nx = 5, ny = 5)
##
## 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(hickory, nx = 7, ny = 7)
##
## Chi-squared test of CSR using quadrat counts
##
## data: hickory
## X2 = 319.17, df = 48, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 7 by 7 grid of tiles
Question 13:
# given: plot(apply(nndist(rpoispp(500), k=1:500), 2, FUN = mean))
#other way 1:
apply(nndist(rpoispp(500), k=1:500), 2, FUN = mean)|> plot()

#other way 2:
nn_means <- apply(nndist(rpoispp(500), k = 1:500), 2, mean)
plot(nn_means,
xlab = "Neighbor Order (k)",
ylab = "Average Nearest Neighbor Distance",
main = "Mean NND (Stored in Variable)")

Question 14: This suggests that maple trees are closer together than
they would be at random
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(split(lansing)$maple, k = 1:100)
ann_values <- colMeans(nn_distances)
points(1:length(ann_values), ann_values,
pch = 5) #Open squares for points

Question 15: the plot suggestese the cells are clustering
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)

Question 16: The data goes slightly above the confidence band,
suggesting some clustering / clumping
G_env_hickory <- envelope(split(lansing)$hickory, Gest, 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(G_env_hickory)

Question 17: The data goes above the confidence band for most of the
plot, suggesting that the points cluster / clump together
G_env_blackoak <- envelope(split(lansing)$blackoak, Gest, 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(G_env_blackoak)

Question 18: The data goes below the confidence band, suggesting
some that the data is regular rather than random
G_env_cells <- envelope(cells, Gest, 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(G_env_cells)

Question 19: The data goes above the confidence band for most of the
plot, suggesting that the points cluster / clump together
data(longleaf)
G_env_longleaf <- envelope(longleaf, Gest, 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(G_env_longleaf)
