ggwr.basic: Generalised GWR models with Poisson and Binomial options

Description Usage Arguments Value Note Author(s) References Examples

View source: R/GeneralizedGWR.r

Description

This function implements generalised GWR

Usage

1
2
3
4
5
6
7
8
ggwr.basic(formula, data, regression.points, bw, family =
                 "poisson", kernel = "bisquare", adaptive = FALSE, cv =
                 T, tol = 1e-05, maxiter = 20, p = 2, theta = 0,
                 longlat = F, dMat, dMat1)

 ## S3 method for class 'ggwrm'
print(x, ...)
 

Arguments

formula

Regression model formula of a formula object

data

a Spatial*DataFrame, i.e. SpatialPointsDataFrame or SpatialPolygonsDataFrame as defined in package sp

regression.points

a Spatial*DataFrame object, i.e. SpatialPointsDataFrame or SpatialPolygonsDataFrame as defined in package sp

bw

bandwidth used in the weighting function, possibly calculated by bw.ggwr();fixed (distance) or adaptive bandwidth(number of nearest neighbours)

family

a description of the error distribution and link function to be used in the model, which can be specified by “poisson” or “binomial”

kernel

function chosen as follows:

gaussian: wgt = exp(-.5*(vdist/bw)^2);

exponential: wgt = exp(-vdist/bw);

bisquare: wgt = (1-(vdist/bw)^2)^2 if vdist < bw, wgt=0 otherwise;

tricube: wgt = (1-(vdist/bw)^3)^3 if vdist < bw, wgt=0 otherwise;

boxcar: wgt=1 if dist < bw, wgt=0 otherwise

adaptive

if TRUE calculate an adaptive kernel where the bandwidth corresponds to the number of nearest neighbours (i.e. adaptive distance); default is FALSE, where a fixed kernel is found (bandwidth is a fixed distance)

cv

if TRUE, cross-validation data will be calculated

tol

the threshold that determines the convergence of the IRLS procedure

maxiter

the maximum number of times to try the IRLS procedure

p

the power of the Minkowski distance, default is 2, i.e. the Euclidean distance

theta

an angle in radians to rotate the coordinate system, default is 0

longlat

if TRUE, great circle distances will be calculated

dMat

a pre-specified distance matrix between regression points and observations, it can be calculated by the function gw.dist

dMat1

a square distance matrix between each pair of observations, it can be calculated by the function gw.dist

x

an object of class “ggwrm”, returned by the function gwr.generalised

...

arguments passed through (unused)

Value

A list of class “ggwrm”:

GW.arguments

a list class object including the model fitting parameters for generating the report file

GW.diagnostic

a list class object including the diagnostic information of the model fitting

glm.res

an object of class inheriting from “glm” which inherits from the class “lm”, see glm.

SDF

a SpatialPointsDataFrame (may be gridded) or SpatialPolygonsDataFrame object (see package “sp”) integrated with fit.points,GWR coefficient estimates, y value,predicted values, coefficient standard errors and t-values in its "data" slot.

CV

a data vector consisting of the cross-validation data

Note

Note that this function calibrates a Generalised GWR model via an approximating algorithm, which is different from the back-fitting algorithm used in the GWR4 software by Tomoki Nakaya.

Author(s)

Binbin Lu [email protected]

References

Nakaya, T., A. S. Fotheringham, C. Brunsdon & M. Charlton (2005) Geographically weighted Poisson regression for disease association mapping. Statistics in Medicine, 24, 2695-2717.

Nakaya, T., M. Charlton, S. Fotheringham & C. Brunsdon. 2009. How to use SGWRWIN (GWR4.0). Maynooth, Ireland: National Centre for Geocomputation.

Fotheringham S, Brunsdon, C, and Charlton, M (2002), Geographically Weighted Regression: The Analysis of Spatially Varying Relationships, Chichester: Wiley.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(LondonHP)
## Not run: 
DM<-gw.dist(dp.locat=coordinates(londonhp))
bw.f1 <- bw.ggwr(BATH2~FLOORSZ,data=londonhp, dMat=DM)
res.poisson<-ggwr.basic(BATH2~FLOORSZ, bw=bw.f1,data=londonhp, dMat=DM)
bw.f2 <- bw.ggwr(BATH2~FLOORSZ,data=londonhp, dMat=DM,family ="binomial")
res.binomial<-ggwr.basic(BATH2~FLOORSZ, bw=bw.f2,data=londonhp, dMat=DM,
              family ="binomial")

## End(Not run)

Example output

Loading required package: maptools
Loading required package: sp
Checking rgeos availability: TRUE
Loading required package: robustbase
Loading required package: Rcpp
Welcome to GWmodel version 2.0-4.
 Note: This verision has been re-built with RcppArmadillo to improve its performance.
 Iteration    Log-Likelihood(With bandwidth:  28008.52 )
=========================
       0       -89.23 
       1       -131.9 
       2       -91.73 
       3       -84.97 
       4          -84 
       5       -84.43 
       6       -84.53 
       7        -84.5 
       8        -84.5 
       9        -84.5 
      10        -84.5 
Fixed bandwidth: 28008.52 CV score: 45.43425 
 Iteration    Log-Likelihood(With bandwidth:  17313.68 )
=========================
       0       -90.01 
       1       -127.9 
       2       -99.76 
       3       -83.54 
       4       -82.14 
       5       -82.18 
       6       -82.43 
       7       -82.42 
       8       -82.37 
       9       -82.37 
      10       -82.38 
      11       -82.38 
Fixed bandwidth: 17313.68 CV score: 27.92392 
 Iteration    Log-Likelihood(With bandwidth:  10703.9 )
=========================
       0       -89.56 
       1       -258.4 
       2         -179 
       3       -132.9 
       4       -88.31 
       5       -81.73 
       6       -77.52 
       7       -77.68 
       8       -78.01 
       9       -77.95 
      10       -77.67 
      11       -77.71 
      12       -77.82 
      13       -77.81 
      14       -77.75 
      15       -77.76 
      16       -77.79 
      17       -77.78 
      18       -77.77 
      19       -77.77 
Fixed bandwidth: 10703.9 CV score: 24.03628 
 Iteration    Log-Likelihood(With bandwidth:  6618.837 )
=========================
       0       -89.75 
       1       -920.5 
       2       -821.8 
       3       -664.9 
       4       -424.9 
       5       -259.7 
       6       -147.4 
       7       -97.53 
       8        -90.1 
       9       -94.23 
      10       -102.2 
      11       -103.4 
      12       -99.52 
      13       -100.7 
      14       -101.9 
      15       -102.1 
      16       -100.6 
      17       -100.6 
      18       -101.5 
      19         -102 
Fixed bandwidth: 6618.837 CV score: 393.7846 
 Iteration    Log-Likelihood(With bandwidth:  13228.61 )
=========================
       0       -90.23 
       1       -283.9 
       2         -160 
       3       -107.4 
       4       -85.13 
       5       -81.21 
       6       -79.43 
       7       -79.81 
       8       -80.36 
       9       -80.17 
      10       -79.91 
      11          -80 
      12       -80.11 
      13       -80.07 
      14       -80.02 
      15       -80.03 
      16       -80.06 
      17       -80.05 
      18       -80.04 
      19       -80.04 
Fixed bandwidth: 13228.61 CV score: 24.8533 
 Iteration    Log-Likelihood(With bandwidth:  9143.547 )
=========================
       0       -89.08 
       1         -308 
       2       -290.7 
       3       -163.7 
       4       -103.8 
       5       -81.54 
       6       -76.21 
       7       -79.01 
       8       -79.18 
       9       -77.39 
      10       -77.31 
      11       -78.16 
      12       -78.19 
      13       -77.68 
      14       -77.68 
      15       -77.96 
      16       -77.94 
      17       -77.79 
      18        -77.8 
      19       -77.89 
Fixed bandwidth: 9143.547 CV score: 40.52803 
 Iteration    Log-Likelihood(With bandwidth:  11668.26 )
=========================
       0       -89.93 
       1       -293.5 
       2       -153.1 
       3       -116.3 
       4       -84.79 
       5       -81.02 
       6       -78.27 
       7       -78.58 
       8       -79.19 
       9       -79.04 
      10       -78.69 
      11       -78.77 
      12       -78.92 
      13       -78.89 
      14       -78.81 
      15       -78.83 
      16       -78.86 
      17       -78.86 
      18       -78.84 
      19       -78.84 
Fixed bandwidth: 11668.26 CV score: 24.34375 
 Iteration    Log-Likelihood(With bandwidth:  10107.9 )
=========================
       0       -89.35 
       1       -263.9 
       2       -203.5 
       3       -145.9 
       4       -90.83 
       5       -82.31 
       6       -77.32 
       7       -77.39 
       8       -77.36 
       9       -77.36 
      10       -77.18 
      11       -77.17 
      12       -77.23 
      13       -77.25 
      14       -77.22 
      15       -77.21 
      16       -77.22 
      17       -77.23 
      18       -77.22 
      19       -77.22 
Fixed bandwidth: 10107.9 CV score: 24.59553 
 Iteration    Log-Likelihood(With bandwidth:  11072.25 )
=========================
       0       -89.71 
       1       -265.4 
       2       -166.1 
       3       -124.7 
       4       -86.54 
       5       -81.24 
       6       -77.77 
       7       -78.01 
       8       -78.48 
       9       -78.38 
      10       -78.06 
      11       -78.13 
      12       -78.26 
      13       -78.23 
      14       -78.17 
      15       -78.18 
      16       -78.21 
      17        -78.2 
      18       -78.19 
      19       -78.19 
Fixed bandwidth: 11072.25 CV score: 24.18097 
 Iteration    Log-Likelihood(With bandwidth:  10476.25 )
=========================
       0       -89.48 
       1       -258.4 
       2       -188.1 
       3       -138.3 
       4       -89.42 
       5       -82.06 
       6       -77.42 
       7       -77.52 
       8       -77.74 
       9       -77.71 
      10       -77.45 
      11       -77.47 
      12       -77.58 
      13       -77.57 
      14       -77.52 
      15       -77.52 
      16       -77.54 
      17       -77.54 
      18       -77.53 
      19       -77.53 
Fixed bandwidth: 10476.25 CV score: 24.06147 
 Iteration    Log-Likelihood(With bandwidth:  10844.6 )
=========================
       0       -89.62 
       1       -260.1 
       2       -173.7 
       3       -129.6 
       4        -87.6 
       5       -81.53 
       6       -77.61 
       7       -77.79 
       8       -78.19 
       9       -78.11 
      10       -77.81 
      11       -77.86 
      12       -77.99 
      13       -77.97 
      14        -77.9 
      15       -77.92 
      16       -77.95 
      17       -77.94 
      18       -77.93 
      19       -77.93 
Fixed bandwidth: 10844.6 CV score: 24.07612 
 Iteration    Log-Likelihood(With bandwidth:  10616.95 )
=========================
       0       -89.53 
       1         -258 
       2       -182.4 
       3         -135 
       4       -88.74 
       5       -81.86 
       6       -77.48 
       7       -77.61 
       8        -77.9 
       9       -77.86 
      10       -77.58 
      11       -77.61 
      12       -77.73 
      13       -77.71 
      14       -77.66 
      15       -77.66 
      16       -77.69 
      17       -77.69 
      18       -77.67 
      19       -77.68 
Fixed bandwidth: 10616.95 CV score: 24.03074 
 Iteration    Log-Likelihood(With bandwidth:  10563.21 )
=========================
       0       -89.51 
       1         -258 
       2       -184.6 
       3       -136.3 
       4       -89.01 
       5       -81.94 
       6       -77.45 
       7       -77.57 
       8       -77.84 
       9        -77.8 
      10       -77.53 
      11       -77.56 
      12       -77.67 
      13       -77.66 
      14        -77.6 
      15       -77.61 
      16       -77.63 
      17       -77.63 
      18       -77.62 
      19       -77.62 
Fixed bandwidth: 10563.21 CV score: 24.03576 
 Iteration    Log-Likelihood(With bandwidth:  10650.16 )
=========================
       0       -89.54 
       1       -258.1 
       2       -181.1 
       3       -134.2 
       4       -88.58 
       5       -81.82 
       6       -77.49 
       7       -77.64 
       8       -77.94 
       9       -77.89 
      10       -77.61 
      11       -77.65 
      12       -77.76 
      13       -77.75 
      14       -77.69 
      15        -77.7 
      16       -77.73 
      17       -77.72 
      18       -77.71 
      19       -77.71 
Fixed bandwidth: 10650.16 CV score: 24.03098 
 Iteration    Log-Likelihood(With bandwidth:  10596.42 )
=========================
       0       -89.52 
       1         -258 
       2       -183.2 
       3       -135.5 
       4       -88.84 
       5        -81.9 
       6       -77.47 
       7        -77.6 
       8       -77.88 
       9       -77.83 
      10       -77.56 
      11       -77.59 
      12        -77.7 
      13       -77.69 
      14       -77.63 
      15       -77.64 
      16       -77.67 
      17       -77.66 
      18       -77.65 
      19       -77.65 
Fixed bandwidth: 10596.42 CV score: 24.03184 
 Iteration    Log-Likelihood(With bandwidth:  10629.63 )
=========================
       0       -89.54 
       1         -258 
       2       -181.9 
       3       -134.7 
       4       -88.68 
       5       -81.85 
       6       -77.48 
       7       -77.62 
       8       -77.92 
       9       -77.87 
      10       -77.59 
      11       -77.63 
      12       -77.74 
      13       -77.73 
      14       -77.67 
      15       -77.68 
      16        -77.7 
      17        -77.7 
      18       -77.69 
      19       -77.69 
Fixed bandwidth: 10629.63 CV score: 24.03054 
 Iteration    Log-Likelihood(With bandwidth:  10637.47 )
=========================
       0       -89.54 
       1       -258.1 
       2       -181.6 
       3       -134.5 
       4       -88.64 
       5       -81.83 
       6       -77.49 
       7       -77.63 
       8       -77.93 
       9       -77.88 
      10        -77.6 
      11       -77.64 
      12       -77.75 
      13       -77.73 
      14       -77.68 
      15       -77.69 
      16       -77.71 
      17       -77.71 
      18        -77.7 
      19        -77.7 
Fixed bandwidth: 10637.47 CV score: 24.0306 
 Iteration    Log-Likelihood
=========================
       0       -79.73 
       1       -82.18 
       2       -72.66 
       3       -67.98 
       4        -66.2 
       5       -65.63 
       6       -65.59 
       7       -65.63 
       8       -65.63 
       9       -65.62 
      10       -65.62 
 Iteration    Log-Likelihood:(With bandwidth:  28008.52 )
=========================
       0       -40.23 
       1        -46.8 
       2       -50.19 
       3       -51.14 
       4       -51.21 
       5       -51.19 
       6       -51.19 
       7       -51.19 
       8       -51.19 
Fixed bandwidth: 28008.52 CV score: 22.834 
 Iteration    Log-Likelihood:(With bandwidth:  17313.68 )
=========================
       0        -40.9 
       1       -46.92 
       2       -50.17 
       3       -51.35 
       4       -51.58 
       5       -51.61 
       6       -51.61 
       7       -51.61 
       8       -51.61 
Fixed bandwidth: 17313.68 CV score: 23.25009 
 Iteration    Log-Likelihood:(With bandwidth:  34618.29 )
=========================
       0        -40.1 
       1       -46.79 
       2       -50.31 
       3       -51.29 
       4       -51.35 
       5       -51.34 
       6       -51.34 
Fixed bandwidth: 34618.29 CV score: 22.64521 
 Iteration    Log-Likelihood:(With bandwidth:  38703.36 )
=========================
       0       -40.11 
       1       -46.88 
       2       -50.48 
       3       -51.48 
       4       -51.55 
       5       -51.54 
       6       -51.54 
       7       -51.54 
Fixed bandwidth: 38703.36 CV score: 22.5932 
 Iteration    Log-Likelihood:(With bandwidth:  41228.07 )
=========================
       0       -40.12 
       1       -46.94 
       2       -50.57 
       3       -51.59 
       4       -51.66 
       5       -51.66 
       6       -51.66 
       7       -51.66 
Fixed bandwidth: 41228.07 CV score: 22.57522 
 Iteration    Log-Likelihood:(With bandwidth:  42788.42 )
=========================
       0       -40.13 
       1       -46.96 
       2       -50.62 
       3       -51.64 
       4       -51.72 
       5       -51.72 
       6       -51.72 
       7       -51.72 
Fixed bandwidth: 42788.42 CV score: 22.56519 
 Iteration    Log-Likelihood:(With bandwidth:  43752.78 )
=========================
       0       -40.13 
       1       -46.98 
       2       -50.64 
       3       -51.67 
       4       -51.75 
       5       -51.75 
       6       -51.75 
       7       -51.75 
Fixed bandwidth: 43752.78 CV score: 22.55917 
 Iteration    Log-Likelihood:(With bandwidth:  44348.78 )
=========================
       0       -40.13 
       1       -46.99 
       2       -50.66 
       3       -51.69 
       4       -51.77 
       5       -51.77 
       6       -51.77 
       7       -51.77 
Fixed bandwidth: 44348.78 CV score: 22.55555 
 Iteration    Log-Likelihood:(With bandwidth:  44717.13 )
=========================
       0       -40.13 
       1       -46.99 
       2       -50.66 
       3        -51.7 
       4       -51.78 
       5       -51.78 
       6       -51.78 
       7       -51.78 
Fixed bandwidth: 44717.13 CV score: 22.55335 
 Iteration    Log-Likelihood:(With bandwidth:  44944.78 )
=========================
       0       -40.13 
       1       -46.99 
       2       -50.67 
       3        -51.7 
       4       -51.79 
       5       -51.78 
       6       -51.78 
       7       -51.78 
Fixed bandwidth: 44944.78 CV score: 22.55202 
 Iteration    Log-Likelihood:(With bandwidth:  45085.48 )
=========================
       0       -40.13 
       1       -46.99 
       2       -50.67 
       3       -51.71 
       4       -51.79 
       5       -51.79 
       6       -51.79 
       7       -51.79 
Fixed bandwidth: 45085.48 CV score: 22.5512 
 Iteration    Log-Likelihood:(With bandwidth:  45172.44 )
=========================
       0       -40.13 
       1       -46.99 
       2       -50.67 
       3       -51.71 
       4       -51.79 
       5       -51.79 
       6       -51.79 
       7       -51.79 
Fixed bandwidth: 45172.44 CV score: 22.55069 
 Iteration    Log-Likelihood:(With bandwidth:  45226.18 )
=========================
       0       -40.13 
       1          -47 
       2       -50.67 
       3       -51.71 
       4        -51.8 
       5       -51.79 
       6       -51.79 
       7       -51.79 
Fixed bandwidth: 45226.18 CV score: 22.55038 
 Iteration    Log-Likelihood:(With bandwidth:  45259.39 )
=========================
       0       -40.13 
       1          -47 
       2       -50.67 
       3       -51.71 
       4        -51.8 
       5       -51.79 
       6       -51.79 
       7       -51.79 
Fixed bandwidth: 45259.39 CV score: 22.55019 
 Iteration    Log-Likelihood:(With bandwidth:  45279.92 )
=========================
       0       -40.13 
       1          -47 
       2       -50.68 
       3       -51.71 
       4        -51.8 
       5       -51.79 
       6       -51.79 
       7       -51.79 
Fixed bandwidth: 45279.92 CV score: 22.55007 
 Iteration    Log-Likelihood:(With bandwidth:  45292.61 )
=========================
       0       -40.13 
       1          -47 
       2       -50.68 
       3       -51.71 
       4        -51.8 
       5       -51.79 
       6       -51.79 
       7       -51.79 
Fixed bandwidth: 45292.61 CV score: 22.55 
 Iteration    Log-Likelihood
=========================
       0       -39.15 
       1       -45.73 
       2       -49.02 
       3       -49.66 
       4       -49.63 
       5       -49.63 
       6       -49.63 
       7       -49.63 

GWmodel documentation built on Feb. 15, 2019, 5:06 p.m.