if (FALSE) {
data(EWHP)
data(EWOutline)
head(ewhp)
houses.spdf <- SpatialPointsDataFrame(ewhp[, 1:2], ewhp)
localstats1 <- gwss(houses.spdf, vars = c("PurPrice", "FlrArea"), bw = 50000)
head(data.frame(localstats1$SDF))
localstats1
##A function for mapping data
if(require("RColorBrewer"))
{
quick.map <- function(spdf,var,legend.title,main.title)
{
x <- spdf@data[,var]
cut.vals <- pretty(x)
x.cut <- cut(x,cut.vals)
cut.levels <- levels(x.cut)
cut.band <- match(x.cut,cut.levels)
colors <- brewer.pal(length(cut.levels), "YlOrRd")
colors <- rev(colors)
par(mar=c(1,1,1,1))
plot(ewoutline,col="olivedrab",bg="lightblue1")
title(main.title)
plot(spdf,add=TRUE,col=colors[cut.band],pch=16)
legend("topleft",cut.levels,col=colors,pch=16,bty="n",title=legend.title)
}
quick.map(localstats1$SDF, "PurPrice_LM", "1000's Uk Pounds",
"Geographically Weighted Mean")
par(mfrow = c(1, 2))
quick.map(localstats1$SDF, "PurPrice_LSKe", "Skewness Level", "Local Skewness")
quick.map(localstats1$SDF, "PurPrice_LSD", "1000's Pounds", "Local Standard Deviation")
#Exploring Non-Stationarity of Relationships
quick.map(localstats1$SDF, "Corr_PurPrice.FlrArea", expression(rho),
"Geographically Weighted Pearson Correlation")
#Robust, Quantile Based Local Summary Statistics
localstats2 <- gwss(houses.spdf, vars = c("PurPrice", "FlrArea"),
bw = 50000, quantile = TRUE)
quick.map(localstats2$SDF, "PurPrice_Median", "1000 UK Pounds",
"Geographically Weighted Median House Price")
}
}
Run the code above in your browser using DataLab