[R-sig-Geo] Mapping exponentials from GWR

Michelle Convey conveymichelle at yahoo.co.uk
Mon Aug 15 11:51:06 CEST 2011


Hi there,

I am working on a project with the spgwr package.  I am able to map the coefficients from my GWR analysis and am able to get summary data on the exponentials on the same data, but am not sure how to map them.  I'm probably missing something quite obvious as I am fairly new to this, but any help would be greatly appreciated. Please see a snippet of the code below:

library spgwr
library maptools
library GISTools

## GWR
# Get the bandwidth:
    a.bw <- gwr.sel(aa~bb, data = data.pt, adapt = TRUE)
    a.bw
# Create model:
    gwr.a = gwr(aa~bb, data=data.pt, adapt=a.bw, fit.points=grid1)

# Co-efficients summary:
m <- length(gwr.a$lm$coefficients)
    CM <- t(apply(as(gwr.a$SDF, "data.frame")[, (1 + (1:m)), drop = FALSE], 
        2, summary))[, c(1:3, 5, 6)]
# This puts it in a matrix:
    if (is.null(dim(CM))) 
        CM <- t(as.matrix(CM))
# Exponentials:
    CM <- cbind(exp(CM), exp(coefficients(gwr.a$lm)))
# This prints out a summary matrix:
    colnames(CM) <- c(colnames(CM)[1:5], "Global")
    printCoefmat(CM)

## MAKE MAP - This only maps the coeffiecients - I would like to be able to map the exponentials
# Plot the results:
    gwr.a = SpatialPixelsDataFrame(gwr.a$SDF, data.frame(gwr.a$SDF))

# Changes colour and map quantiles:    
    gwr.shades = auto.shading(gwr.res_a$bb, n=4, cols=brewer.pal(4,'Blues'),cutter=quantile.cuts)
    level.plot(gwr.res_a, index = "LTI", shades = gwr.shades)

Any help would be gratefully received.

Many thanks,
M




More information about the R-sig-Geo mailing list