Q <- quadratcount(bei, nx=6, ny=3)
plot(bei, cex=0.5, pch="+")
plot(Q, add=TRUE, cex=2)

Problem 1
Row 2 column 2, and row 2 column 3.
den <- density(bei)
plot(den)
plot(bei, add=T, cex=0.5)

persp(den)

contour(den)

Problem 2
0.022
mytess <- hextess(bei, 50)
Q <- quadratcount(bei, tess=mytess)
plot(bei, cex=0.5, pch="+")
plot(Q, add=TRUE, cex=1)

mytess10 <- hextess(bei, 10)
Q10 <- quadratcount(bei, tess=mytess10)
plot(bei, cex=0.5, pch="+")
plot(Q10, add=TRUE, cex=1)

quadrat.test(bei, tess = mytess10)
## Warning: Some expected counts are small; chi^2 approximation may be inaccurate
##
## Chi-squared test of CSR using quadrat counts
##
## data: bei
## X2 = 12836, df = 1976, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 1977 tiles (irregular windows)
Problem 3
After conducting a quadrat test, the returned p-value of <
2.2e-16 means we reject the null hypothesis of complete spatial
awareness. This means the values are most likely clustered.
slope <- bei.extra$grad
elev <- bei.extra$elev
b <- quantile(slope, probs = (0:4)/4)
slopecut <- cut(slope, breaks=b, labels=1:4)
V <- tess(image = slopecut)
plot(V)
plot(bei, add=T, pch ="+")

quadcount <- quadratcount(bei, tess=V)
plot(quadcount)

quadrat.test(bei, tess=V)
##
## Chi-squared test of CSR using quadrat counts
##
## data: bei
## X2 = 661.84, df = 3, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 4 tiles (levels of a pixel image)
Problem 4
b_slope <- quantile(slope, probs = (0:5)/5)
slopecut <- cut(slope, breaks=b_slope, labels=1:5)
V_slope <- tess(image = slopecut)
plot(V_slope)
plot(bei, add=T, pch ="+")

quadcount <- quadratcount(bei, tess=V_slope)
plot(quadcount)

quadrat.test(bei, tess=V_slope)
##
## Chi-squared test of CSR using quadrat counts
##
## data: bei
## X2 = 587, df = 4, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 5 tiles (levels of a pixel image)
b_elev <- quantile(elev, probs = (0:5)/5)
elevcut <- cut(elev, breaks=b_elev, labels=1:5)
V_elev <- tess(image = elevcut)
plot(V_elev)
plot(bei, add=T, pch ="+")

quadcount <- quadratcount(bei, tess=V_elev)
plot(quadcount)

quadrat.test(bei, tess=V_elev)
##
## Chi-squared test of CSR using quadrat counts
##
## data: bei
## X2 = 567.09, df = 4, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 5 tiles (levels of a pixel image)
Problem 5
0% - 0.0008663357, 20% - 0.03512632, 40% - 0.05314778, 60% -
0.07807091, 80% - 0.1287942, 100% - 0.3284767.
Problem 6
quadcount
## tile
## 1 2 3 4 5
## 490 719 861 1174 360
Problem 7
quadrat.test(bei, tess = V_slope)
##
## Chi-squared test of CSR using quadrat counts
##
## data: bei
## X2 = 587, df = 4, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 5 tiles (levels of a pixel image)
quadrat.test(bei, tess = V_elev)
##
## Chi-squared test of CSR using quadrat counts
##
## data: bei
## X2 = 567.09, df = 4, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 5 tiles (levels of a pixel image)
Both slope and elevation produced significant p-values (<
2.2e-16), meaning there are strong deviations from complete spatial
randomness. Because the p-values are identical and extremely small,
neither covariate clearly stands out as a stronger explanatory factor
based on the quadrat test alone. This means both variables probably
influence tree distribution.
plot(rhohat(bei, slope))

I believe the red dashed line represents overall mean density of
points across the study area. It gives a baseline to compare how point
intensity varies with the slope.
Problem 9
This plot suggests that tree distribution varies with slope,
particularly that these trees prefer moderate and higher slopes over
flatter terrain. This could be because flatter areas are more prone to
flooding and steeper terrain is better for drainage.
model <- ppm(bei ~ slope * elev)
summary(model)
## Point process model
## Fitted to data: bei
## Fitting method: maximum likelihood (Berman-Turner approximation)
## Model was fitted using glm()
## Algorithm converged
## Call:
## ppm.formula(Q = bei ~ slope * elev)
## Edge correction: "border"
## [border correction distance r = 0 ]
## --------------------------------------------------------------------------------
## Quadrature scheme (Berman-Turner) = data + dummy + weights
##
## Data pattern:
## Planar point pattern: 3604 points
## Average intensity 0.00721 points per square metre
## Window: rectangle = [0, 1000] x [0, 500] metres
## Window area = 5e+05 square metres
## Unit of length: 1 metre
##
## Dummy quadrature points:
## 130 x 130 grid of dummy points, plus 4 corner points
## dummy spacing: 7.692308 x 3.846154 metres
##
## Original dummy parameters: =
## Planar point pattern: 16904 points
## Average intensity 0.0338 points per square metre
## Window: rectangle = [0, 1000] x [0, 500] metres
## Window area = 5e+05 square metres
## Unit of length: 1 metre
## Quadrature weights:
## (counting weights based on 130 x 130 array of rectangular tiles)
## All weights:
## range: [1.64, 29.6] total: 5e+05
## Weights on data points:
## range: [1.64, 14.8] total: 41000
## Weights on dummy points:
## range: [1.64, 29.6] total: 459000
## --------------------------------------------------------------------------------
## FITTED :
##
## Nonstationary Poisson process
##
## ---- Intensity: ----
##
## Log intensity: ~slope * elev
## Model depends on external covariates 'slope' and 'elev'
## Covariates provided:
## slope: im
## elev: im
##
## Fitted trend coefficients:
## (Intercept) slope elev slope:elev
## -4.403426761 -36.500458701 -0.007024363 0.292813497
##
## Estimate S.E. CI95.lo CI95.hi Ztest
## (Intercept) -4.403426761 0.614763210 -5.60834051 -3.198513010 ***
## slope -36.500458701 5.261456400 -46.81272375 -26.188193651 ***
## elev -0.007024363 0.004192219 -0.01524096 0.001192235
## slope:elev 0.292813497 0.036257125 0.22175084 0.363876155 ***
## Zval
## (Intercept) -7.162801
## slope -6.937330
## elev -1.675572
## slope:elev 8.076026
##
## ----------- gory details -----
##
## Fitted regular parameters (theta):
## (Intercept) slope elev slope:elev
## -4.403426761 -36.500458701 -0.007024363 0.292813497
##
## Fitted exp(theta):
## (Intercept) slope elev slope:elev
## 1.223534e-02 1.406217e-16 9.930002e-01 1.340193e+00
plot(model)


Problem 10
Based on the Z-values, the intercept, slope, and slope:elevation
interaction are statistically significant. Only elevation is not
significant. Essentially, the intercept, slope, and slope:elevation
affect tree density, where elevation does not.
Problem 11
The coefficients for the ppm model are -4.4 for the intercept, -36.5
for the slop, nearly 0 for the elevation, and 0.3 for slope:elev. In the
bivariate slrm case, the intercept is -5.7 and the slope is 6.5. In the
multivariate slrm case, the intercept is -4.3, slope is -36.3, elevation
is nearly 0, and slope:elev is 0.3. The ppm model and multivariate slrm
model return very similar——almost identical——values. Where ppm predicts
intensity, or expected number of points per unit area, slrm predicts
probability, or the likelihood of an event at a given location.
gor_subset1 <- gorillas[marks(gorillas)$group == "minor" &
marks(gorillas)$season == "rainy", ]
summary(gor_subset1)
## Marked planar point pattern: 172 points
## Average intensity 8.654672e-06 points per square metre
##
## *Pattern contains duplicated points*
##
## Coordinates are given to 2 decimal places
## i.e. rounded to the nearest multiple of 0.01 metres
##
## Mark variables: group, season, date
## Summary:
## group season date
## major: 0 dry : 0 Min. :2006-04-25
## minor:172 rainy:172 1st Qu.:2007-09-03
## Median :2008-06-13
## Mean :2008-04-09
## 3rd Qu.:2008-08-21
## Max. :2009-05-28
##
## Window: polygonal boundary
## single connected closed polygon with 21 vertices
## enclosing rectangle: [580457.9, 585934] x [674172.8, 678739.2] metres
## (5476 x 4566 metres)
## Window area = 19873700 square metres
## Unit of length: 1 metre
## Fraction of frame area: 0.795
gor_subset2 <- gorillas[marks(gorillas)$group == "major" &
marks(gorillas)$season == "dry", ]
summary(gor_subset2)
## Marked planar point pattern: 150 points
## Average intensity 7.547679e-06 points per square metre
##
## Coordinates are given to 2 decimal places
## i.e. rounded to the nearest multiple of 0.01 metres
##
## Mark variables: group, season, date
## Summary:
## group season date
## major:150 dry :150 Min. :2006-01-06
## minor: 0 rainy: 0 1st Qu.:2006-12-13
## Median :2007-12-05
## Mean :2007-10-22
## 3rd Qu.:2008-12-16
## Max. :2009-03-30
##
## Window: polygonal boundary
## single connected closed polygon with 21 vertices
## enclosing rectangle: [580457.9, 585934] x [674172.8, 678739.2] metres
## (5476 x 4566 metres)
## Window area = 19873700 square metres
## Unit of length: 1 metre
## Fraction of frame area: 0.795
Problem 12
There are 150 sites in this reduced dataset.
veg_tess <- tess(image = gorillas.extra$vegetation)
quadratcount(gor_subset2, tess=veg_tess)
## tile
## Disturbed Colonising Grassland Primary Secondary Transition
## 24 0 2 120 2 2
quadrat.test(gor_subset2, tess=veg_tess)
## Warning: Some expected counts are small; chi^2 approximation may be inaccurate
##
## Chi-squared test of CSR using quadrat counts
##
## data: gor_subset2
## X2 = 183.29, df = 5, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 6 tiles (levels of a pixel image)
Problem 14
The quadrat test returned a p-value of 0.81, which indicates a lack
of evidence for non-random distribution. Essentially, there is no clear
relationship between nests and slope type. The slope type with the
highest number of nests is Ridge with 58. Valley is next with 55, then
Midslope with 21, Toe with 12, Upper at 4, and Flat with none.
elev_g <- gorillas.extra$elevation
b_elev_g <- quantile(elev_g, probs = (0:5)/5)
elevcut_g <- cut(elev_g, breaks = b_elev_g, labels = 1:5, include_lowest = TRUE)
V_elev_g <- tess(image = elevcut_g)
quadrat.test(gor_subset2, tess = V_elev_g)
##
## Chi-squared test of CSR using quadrat counts
##
## data: gor_subset2
## X2 = 176.79, df = 4, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 5 tiles (levels of a pixel image)
slope_g <- gorillas.extra$slopeangle
b_slope_g <- quantile(slope_g, probs = (0:5)/5)
slopecut_g <- cut(slope_g, breaks = b_slope_g, labels = 1:5, include_lowest = TRUE)
V_slope_g <- tess(image = slopecut_g)
quadrat.test(gor_subset2, tess = V_slope_g)
##
## Chi-squared test of CSR using quadrat counts
##
## data: gor_subset2
## X2 = 12.078, df = 4, p-value = 0.03356
## alternative hypothesis: two.sided
##
## Quadrats: 5 tiles (levels of a pixel image)
Problem 16
The results of the slrm model indicate that there is a very high
likelihood that nest sites correlate to slopangle and elevation, with
elevation at a much higher likelihood than slopeangle or both combined.
The prediction map illustrates these results, with nests clustered
around the highest elevation areas as well as at a lower elevation to
the upper left.