[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
Mon Jul 5 15:58:10 CEST 2021


Ok, thank you for your comments.
Regards, Manuel

Sent from Mail for Windows 10

From: binbinlu using whu.edu.cn
Sent: 4 de julho de 2021 09:24
To: mr; r-sig-geo
Subject: Re: [R-sig-Geo] Gwmodel an spgwr return too different local coefficients?

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


binbinlu using whu.edu.cn
 
From: mr via R-sig-Geo
Date: 2021-07-04 01:11
To: r-sig-geo using 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 using r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20210705/52b24ead/attachment.html>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 44B618F6EBBA4A9787CC8D4514D9167B.png
Type: image/png
Size: 129 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20210705/52b24ead/attachment.png>


More information about the R-sig-Geo mailing list