需要空间统计帮助

时间:2019-12-13 18:56:52

标签: statistics rstudio geospatial shapefile autocorrelation

我需要运行3个统计测试,其中2个需要进行空间测试。我想找到美国东海岸的星巴克和Dunkin Donut地点之间的空间自相关。我遇到了如何运行Moran I测试的问题,需要帮助。


标题:“ ProjectFirstFewLines” 作者:“斯蒂芬·斯普林斯汀” 日期:“ 12/13/2019”

输出:html_document

knitr::opts_chunk$set(echo = TRUE)
require("knitr")
#opts_knit$set(root.dir = "C:/Workspace/RFiles/")

r <- getOption("repos")
r["CRAN"] <- "http://cran.us.r-project.org"
options(repos = r)
dir <- "C:/School/GEO460G"
setwd(dir)
library(spdep)
library(classInt)
library(rgdal)
library(sf)
library(maptools)
# Load in Puerto Rico shapefile
starbucks <- readOGR("Starbucks/EasternStarbucks.shp")
dunkin <- readOGR("DunkinDonuts/EasternDunkinDonuts.shp")

summary(starbucks)
summary(dunkin)

plot(starbucks, lwd=1.5)
plot(dunkin, add=T, col="gray")

head(starbucks)
head(dunkin)

# dunk.nb <- poly2nb(dunkin)
# dunk.listw <- nb2listw(dunk.nb, style = "B")
# Spatial autocorrelation tests
#moran.test(starbucks, dunkin)
#moran.mc(starbucks, dunkin, nsim = 599)
#geary.test(starbucks, dunkin)
#moran.plot(starbucks, dunkin, pch=20)

# Calculate empiracal variogram for Starbucks
#star.v <- variogram(starbucks ~ 1, pr)
# Fit empiracal to the theoretical
#star.v.fit <- fit.variogram(star.v, vgm(11, "Sph", "30000", 1))
# Plot the fitted and empircal
#plot(star.v, star.v.fit)

# Calculate empiracal variogram for Dunkin Donuts
#star.v <- variogram(dunkin ~ 1, pr)
# Fit empiracal to the theoretical
#dunk.v.fit <- fit.variogram(dunk.v, vgm(11, "Sph", "30000", 1))
# Plot the fitted and empircal
#plot(dunk.v, dunk.v.fit)

0 个答案:

没有答案