# NOT RUN {
data(LondonHP)
DM<-gw.dist(dp.locat=coordinates(londonhp))
##Compare the time consumed with and without a specified distance matrix
# }
# NOT RUN {
system.time(gwr.res<-gwr.basic(PURCHASE~FLOORSZ, data=londonhp, bw=1000,
kernel = "gaussian"))
system.time(DM<-gw.dist(dp.locat=coordinates(londonhp)))
system.time(gwr.res<-gwr.basic(PURCHASE~FLOORSZ, data=londonhp, bw=1000,
kernel = "gaussian", dMat=DM))
## specify an optimum bandwidth by cross-validation appraoch
bw1<-bw.gwr(PURCHASE~FLOORSZ, data=londonhp, kernel = "gaussian",dMat=DM)
gwr.res1<-gwr.basic(PURCHASE~FLOORSZ, data=londonhp, bw=bw1,kernel = "gaussian",
dMat=DM)
gwr.res1
# }
# NOT RUN {
data(LondonBorough)
nsa = list("SpatialPolygonsRescale", layout.north.arrow(), offset = c(561900,200900),
scale = 500, col=1)
# }
# NOT RUN {
if(require("RColorBrewer"))
{
mypalette<-brewer.pal(6,"Spectral")
x11()
spplot(gwr.res1$SDF, "FLOORSZ", key.space = "right", cex=1.5, cuts=10,
ylim=c(155840.8,200933.9), xlim=c(503568.2,561957.5),
main="GWR estimated coefficients for FLOORSZ with a fixed bandwidth",
col.regions=mypalette, sp.layout=list(nsa, londonborough))}
# }
# NOT RUN {
bw2<-bw.gwr(PURCHASE~FLOORSZ,approach="aic",adaptive=TRUE, data=londonhp,
kernel = "gaussian", dMat=DM)
gwr.res2<-gwr.basic(PURCHASE~FLOORSZ, data=londonhp, bw=bw2,adaptive=TRUE,
kernel = "gaussian", dMat=DM)
gwr.res2
if(require("RColorBrewer"))
{
x11()
spplot(gwr.res2$SDF, "FLOORSZ", key.space = "right", cex=1.5, cuts=10,
ylim=c(155840.8,200933.9), xlim=c(503568.2,561957.5),
main="GWR estimated coefficients for FLOORSZ with an adaptive bandwidth",
col.regions=mypalette, sp.layout=list(nsa,londonborough))}
# }
Run the code above in your browser using DataLab