[R-sig-Geo] Gwmodel an spgwr return too different local coefficients?

Danlin Yu yud @end|ng |rom m@||@montc|@|r@edu
Sun Jul 4 07:35:16 CEST 2021


Hi,

Have you checked the bandwidth vector between the two packages (bw_gw 
and bw_sp)? If these two are different then the estimated coefficients 
will be different, too.

Hope this helps.

Danlin

On 2021/7/3 13:11, mr via R-sig-Geo wrote:
> 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

-- 
___________________________________________
Danlin Yu, Ph.D.
Professor of GIS and Urban Geography
Department of Earth & Environmental Studies
Montclair State University
Montclair, NJ, 07043
Tel: 973-655-4313
Fax: 973-655-4072
Office: CELS 314
Email: yud using mail.montclair.edu
webpage: csam.montclair.edu/~yu



More information about the R-sig-Geo mailing list