Q <- quadratcount(bei, nx=6, ny=3)
plot(bei, cex=0.5, pch="+")
plot(Q, add=TRUE, cex=2)
Row 2 column 2 and 3 quandrats have the two lowest density of trees
den <- density(bei)
plot(den)
plot(bei, add=T, cex=0.5)
persp(den)
contour(den)
0.022 is the highest point density countour.
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)
Q <- quadratcount(bei, tess=mytess10)
plot(bei, cex=0.5, pch="+")
plot(Q, add=TRUE, cex=1)
min(Q)
## [1] 0
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)
Minimum 1 P-value <2.2e-16 = Which mean these trees are random.
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)
slope <- bei.extra$grad
elev <- bei.extra$elev
b_slope <- quantile(slope, probs = (0:5)/5)
slopecut <- cut(slope, breaks=b_slope, labels=1:5)
Vslope <- tess(image = slopecut)
b_elev <- quantile(elev, probs = (0:5)/5)
elevcut <- cut(elev, breaks=b_elev, labels=1:5)
Velev <- tess(image = elevcut)
plot(b_slope)
quadcount_elev <- quadratcount(bei, tess=Velev)
quadcount_elev
## tile
## 1 2 3 4 5
## 490 719 861 1174 360
The one with the smaller p-value shows us that it is not random
quadrat.test(bei, tess=Vslope)
##
## 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=Velev)
##
## 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)
plot(rhohat(bei, slope))
The dashed line shows us the expected intensity under complete spatial randomness which would be constant!
Steeper slopes corrolate to trees being less dence to one another
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)
I believe the Variables with stars next to them “***”
model <- slrm(bei ~ slope)
model2 <- slrm(bei ~ slope*elev)
model_ppm <- ppm(bei ~ slope * elev)
model_slrm <- slrm(bei ~ slope * elev)
plot(model_ppm)
plot(model_slrm)
The top plot is showing a trend and an estimate of intensity while the bottom graph is showing the probability of intensity.
gor_subset <- gorillas[marks(gorillas)$group == "minor" &
marks(gorillas)$season == "rainy", ]
npoints(gor_subset)
## [1] 172
172 sites
veg_tess <- tess(image = gorillas.extra$vegetation)
quadratcount(gor_subset, tess=veg_tess)
## tile
## Disturbed Colonising Grassland Primary Secondary Transition
## 18 1 5 140 5 3
quadrat.test(gor_subset, 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_subset
## X2 = 225.47, df = 5, p-value < 2.2e-16
## alternative hypothesis: two.sided
##
## Quadrats: 6 tiles (levels of a pixel image)
Primary contains the most - 140 The p value indicates that they are non-random
slope_tess <- tess(image = gorillas.extra$slopetype)
quad_slope <- quadratcount(gor_subset, tess=slope_tess)
quad_slope
## tile
## Valley Toe Flat Midslope Upper Ridge
## 69 9 1 15 4 74
The Valley contines the most - 69 P-Value is 0.9085 which means this is random
elev <- gorillas.extra$elevation
slopeangle <- gorillas.extra$slopeangle
b_elev_gor <- quantile(elev, probs = (0:5)/5)
b_slope_gor <- quantile(slopeangle, probs = (0:5)/5)
elevcut_gor <- cut(elev, breaks=b_elev_gor, labels=1:5)
slopecut_gor <- cut(slopeangle, breaks=b_slope_gor, labels=1:5)
Velev_gor <- tess(image = elevcut_gor)
Vslope_gor <- tess(image = slopecut_gor)
quadrat.test(gor_subset, tess=Velev_gor)
##
## Chi-squared test of CSR using quadrat counts
##
## data: gor_subset
## X2 = 65.609, df = 4, p-value = 3.831e-13
## alternative hypothesis: two.sided
##
## Quadrats: 5 tiles (levels of a pixel image)
quadrat.test(gor_subset, tess=Vslope_gor)
##
## Chi-squared test of CSR using quadrat counts
##
## data: gor_subset
## X2 = 4.4986, df = 4, p-value = 0.6854
## alternative hypothesis: two.sided
##
## Quadrats: 5 tiles (levels of a pixel image)
The P-Value is 3.831e-13 which means this is non-random
model_gor <- slrm(gor_subset ~ slopeangle * elev)
summary(model_gor)
## Fitted spatial logistic regression model
## Call: [1] "slrm(gor_subset ~ slopeangle * elev)"
## Formula: gor_subset ~ slopeangle * elev
## Fitted coefficients:
## Estimate S.E. CI95.lo CI95.hi Ztest
## (Intercept) -2.355511e+01 2.208010e+00 -2.788273e+01 -1.922749e+01 ***
## slopeangle 2.608868e-01 8.170317e-02 1.007516e-01 4.210221e-01 **
## elev 6.517767e-03 1.215090e-03 4.136235e-03 8.899299e-03 ***
## slopeangle:elev -1.373251e-04 4.585565e-05 -2.272006e-04 -4.744970e-05 **
## Zval
## (Intercept) -10.668027
## slopeangle 3.193105
## elev 5.364021
## slopeangle:elev -2.994726
pred <- predict(model_gor)
plot(pred)
plot(gor_subset, add=TRUE, pch=16, cex=0.5)
## Plotting the first column of marks
This model shows us that slop angle and elevation are likely related to where nests are constructed. As we can see the black dots being each nest and they reside nere higher intesnities on the map.