[R-sig-Geo] Gwmodel an spgwr return too different local coefficients?
mr
m@nue|@r|be|ro @end|ng |rom tecn|co@u||@bo@@pt
Sat Jul 3 19:11:54 CEST 2021
Dear all,
I am using spgwr::ggwr() and GWmodel::ggwr.basic to fit a generalized geographically weighted regression with Poisson model and log-link function.
Local coefficients between packages are very different, but i couldn't find out why. If any body can point me what am i missing, i apreciate a lot.
Below is an example using spData::nc.sids. I would expect local coefficents will be around the observed mean, but this doesnt occur using the GWmodel::ggwr.basic function:
library (spData)
library(GWmodel)
library(spgwr)
library(sp)
data(nc.sids)
nc.sids$SID79 <- nc.sids$SID79 + 1
# formula of glm poisson model
f1 <- SID79 ~ offset(log(BIR79))
# GWmodel
sp::coordinates(nc.sids) <- ~ x + y
dM <- gw.dist(dp.locat = coordinates(nc.sids))
bw_gw <- bw.ggwr(formula(f1), nc.sids, family ="poisson", approach="AIC",
kernel="gaussian", adaptive = T, p = 2, theta = 0, longlat=F, dMat = dM)
m_gw <- ggwr.basic(formula(f1), data = nc.sids,
regression.points = nc.sids, bw = bw_gw,
family = "poisson", kernel = "gaussian",
adaptive = T, cv = F, tol = 1e-5,
maxiter = 1000, dMat = dM)
# spgwr
dfsids <- as.data.frame(nc.sids)
xycoord <- cbind(dfsids$x,dfsids$y)
bw_sp <- ggwr.sel(formula(f1), data = dfsids , family = poisson(link = "log"),
gweight = gwr.Gauss, adapt = T, coords = xycoord,
tol = 1e-5 , verbose = T)
m_sp <- ggwr(formula(f1), data = dfsids, gweight = gwr.Gauss,
adapt = bw_sp, family = poisson(link="log"),
type="working", coords = xycoord)
# compare results
obs <- mean(log(nc.sids$SID79 / nc.sids$BIR79))
gw <- mean(m_gw$SDF$Intercept)
sp <- mean(m_sp$SDF$X.Intercept.)
cbind(obs, sp, gw)
Sent from Mail for Windows 10
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list