Learn R Programming

gwer (version 2.1)

gwer: Geographically Weighted Elliptical Regression

Description

The function fit geographically weighted elliptical regression model to explore the non-stationarity for a certain bandwidth and weighting function.

Usage

gwer(
  formula,
  data,
  coords,
  bandwidth,
  gweight = gwr.Gauss,
  adapt = NULL,
  hatmatrix = FALSE,
  fit.points,
  family = Normal,
  longlat = NULL,
  weights,
  dispersion = NULL,
  subset,
  na.action = "na.fail",
  method = "gwer.fit",
  control = glm.control(epsilon = 1e-04, maxit = 100, trace = F),
  model = FALSE,
  x = FALSE,
  y = TRUE,
  contrasts = NULL,
  offset,
  type = "pearson",
  spdisp = FALSE,
  parplot = FALSE,
  ...
)

Arguments

formula

regression model formula as in glm.

data

model data frame, or may be a SpatialPointsDataFrame or SpatialPolygonsDataFrame as defined in package sp.

coords

matrix of coordinates of points representing the spatial positions of the observations.

bandwidth

value of the selected bandwidth used in the weighting function (see gwer.sel for bandwidth optimization).

gweight

geographical weighting function, at present gwr.Gauss() is default.

adapt

defines the type of bandwidth used. either NULL (default) or a proportion between 0 and 1 of observations to include in weighting scheme (k-nearest neighbours).

hatmatrix

if TRUE, return the hatmatrix as a component of the result, ignored if fit.points given

fit.points

an object containing the coordinates of fit points, often an object from package sp. If missing, the coordinates given through the data argument object, or the coords argument are used.

family

a description of the error distribution to be used in the model (see elliptical.family for details of family functions).

longlat

TRUE if point coordinates are longitude-latitude decimal degrees, in which case distances are measured in kilometers. If x is a SpatialPoints object, the value is taken from the object itself.

weights

an optional numeric vector of weights to be used in the fitting process.

dispersion

an optional fixed value for dispersion parameter.

subset

an optional numeric vector specifying a subset of observations to be used in the fitting process.

na.action

a function which indicates what should happen when the data contain NAs (see glm).

method

the method to be used in fitting local models. The default method "gwer.fit" uses Fisher's scoring method. The alternative "model.frame" returns the model frame and does no fitting.

control

a list of parameters for controlling the fitting process. For elliptical this is passed by glm.control.

model

a logical value indicating whether model frame should be included as a component of the return.

x

a logical value indicating whether the response vector used in the fitting process should be returned as components of the return.

y

a logical value indicating whether model matrix used in the fitting process should be returned as components of the return.

contrasts

an optional list. See the contrasts.arg of model.matrix.default.

offset

this can be used to specify an a priori known component to be included in the linear predictor during fitting as in glm.

type

a character string that indicates the type of residuals should consider as return.

spdisp

if TRUE dispersion parameter varies geographically.

parplot

if TRUE the parameters boxplots are plotted.

...

arguments to be used to form the default control argument if it is not supplied directly.

Value

returns an object of class “gwer”, a list with follow components:

SDF

a SpatialPointsDataFrame (may be gridded) or SpatialPolygonsDataFrame object (see package sp) with fit.points, weights, GWR coefficient estimates, dispersion and the residuals of type in its data slot.

coef

the matrices of coefficients, standard errors and significance values for parameters hypothesis test.

dispersion

either the supplied argument or the estimated dispersion with standard error.

hat

hat matrix of the geographically weighted elliptical model.

lm

elliptical global regression on the same model formula.

results

a list of results values for fitted geographically weighted elliptical model.

bandwidth

the bandwidth used in geographical weighting function.

fitted

the fitted mean values of the geographically weighted elliptical model.

hatmatrix

a logical value indicating if hatmatrix was considered

gweights

a matrix with the geographical weighting for all local elliptical models.

family

the family object used.

flm

a matrix with the fitted values for all local elliptical models.

adapt

the adapt object used.

gweight

the gweights object used.

spdisp

the spdisp object used.

this.call

the function call used.

fp.given

the fp.given object used.

longlat

the longlat object used.

type

the type residuals for the object used.

References

Brunsdon, C., Fotheringham, A. S. and Charlton, M. E. (1996). Geographically weighted regression: a method for exploring spatial nonstationarity. Geographical analysis, 28(4), 281-298. https://doi.org/10.1111/j.1538-4632.1996.tb00936.x

Cysneiros, F. J. A., Paula, G. A., and Galea, M. (2007). Heteroscedastic symmetrical linear models. Statistics & probability letters, 77(11), 1084-1090. https://doi.org/10.1016/j.spl.2007.01.012

Fang, K. T., Kotz, S. and NG, K. W. (1990, ISBN:9781315897943). Symmetric Multivariate and Related Distributions. London: Chapman and Hall.

See Also

gwer.sel, elliptical, family.elliptical

Examples

Run this code
# NOT RUN {
data(columbus, package="spData")
fit.lm <- lm(CRIME ~ INC, data=columbus)
summary(fit.lm)
gwer.bw <- gwer.sel(CRIME ~ INC, data=columbus, family = Normal(),
                 coords=cbind(columbus$X, columbus$Y), method = 'aic')
gwer.fit <- gwer(CRIME ~ INC, family = Normal(), bandwidth = gwer.bw, hatmatrix = TRUE, 
                 spdisp = TRUE, parplot = TRUE, data=columbus, method = "gwer.fit",
                 coords=cbind(columbus$X, columbus$Y))
print(gwer.fit) 
# }
# NOT RUN {
data(columbus, package="spData")
fit.elliptical <- elliptical(CRIME ~ INC, family = Student(df=4), data=columbus)
summary(fit.elliptical)
gwer.bw <- gwer.sel(CRIME ~ INC, data=columbus, family = Student(df=4),
                 coords=cbind(columbus$X, columbus$Y), method = 'aic')
gwer.fitt <- gwer(CRIME ~ INC, family = Student(df=4), bandwidth = gwer.bw, hatmatrix = TRUE,
                 spdisp = TRUE, parplot = TRUE, data=columbus, method = "gwer.fit",
                 coords=cbind(columbus$X, columbus$Y))
print(gwer.fitt)  
# }

Run the code above in your browser using DataLab