台南市學校的空間型態檢定
library(sf)
school=st_read("D:/1092SA/Data/Schools.shp")
#1. Fishnet
grid = st_make_grid(school, 5000) %>% st_sf
#2. Quadart Count
count = st_contains(grid, school) %>% lengths
k = length(count)
#3. VMR
VMR = var(count)/mean(count)
VMR.se= sqrt(2/(k-1))
VMR.t = (VMR-1)/VMR.se
設定顯著水準 \(\alpha=0.05\)
\(H_0\):點分布為隨機分布\((s^2=\lambda , VMR=1)\)
\(H_a\):點分布非隨機分布\((s^2\neq\lambda , VMR\neq1)\)
VMR.p = 2*pt(VMR.t,k-1,lower.tail=VMR.t<0)
VMR.p < 0.05
[1] TRUE
\(p-value<\alpha\),拒絕假設檢定,台南市學校點分布非隨機分布。
library(tmap)
grid$count=count
qtm(grid,fill="count")+qtm(school)