Hi,

In GWmodel, we didn't process the offset term, and that's why the results are 
very different from each other.

Moreover, the bandwidths for them are also different, but this won't cause a 
big difference.

Cheers,
Binbin



binbi...@whu.edu.cn
 
From: mr via R-sig-Geo
Date: 2021-07-04 01:11
To: r-sig-geo@r-project.org
Subject: [R-sig-Geo] Gwmodel an spgwr return too different local coefficients?
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]]
 
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to