MGWRSAR: Estimation of linear and local linear model with spatial...

View source: R/MGWRSAR.R

MGWRSARR Documentation

Estimation of linear and local linear model with spatial autocorrelation model (mgwrsar).

Description

MGWRSAR is is a wrapper function for estimating linear and local linear models with spatial autocorrelation (SAR models with spatially varying coefficients).

Usage

MGWRSAR(formula,data,coord,fixed_vars=NULL,kernels,H,
Model='GWR',control=list())

Arguments

formula

a formula.

data

a dataframe or a spatial dataframe (sp package).

coord

default NULL, a dataframe or a matrix with coordinates, not required if data is a spatial dataframe.

fixed_vars

a vector with the names of spatiallay constant coefficient for mixed model. All other variables present in formula are supposed to be spatially varying. If empty or NULL (default), all variables in formula are supposed to be spatially varying.

kernels

A vector containing the kernel types. Possible types: rectangle ("rectangle"), bisquare ("bisq"), tricube ("tcub"), epanechnikov ("epane"), gaussian ("gauss")) .

H

vector containing the bandwidth parameters for the kernel functions.

Model

character containing the type of model: Possible values are "OLS", "SAR", "GWR" (default), "MGWR" , "MGWRSAR_0_0_kv","MGWRSAR_1_0_kv", "MGWRSAR_0_kc_kv", "MGWRSAR_1_kc_kv", "MGWRSAR_1_kc_0". See Details for more explanation.

control

list of extra control arguments for MGWRSAR wrapper - see Details below

Details

  • Z a matrix of variables for genralized kernel product, default NULL.

  • W a row-standardized spatial weight matrix for Spatial Aurocorrelation, default NULL.

  • type verbose mode, default FALSE.

  • adaptiveA vector of boolean to choose adaptive version for each kernel.

  • kernel_w the type of kernel for computing W, default NULL.

  • h_w the bandwidth value for computing W, default 0.

  • Method estimation technique for computing the models with Spatial Dependence. '2SLS' or 'B2SLS', default '2SLS'.

  • TP A vector of target points, default NULL.

  • isgcv computing LOOCV criteria (for example for selecting optimal bandwidth), default FALSE.

  • isfgcv if TRUE, simplify the computation of CV criteria (remove or not i when using local instruments for model with lambda spatially varying), default TRUE.

  • maxknn when n >NmaxDist, only the maxknn first neighbours are used for distance compution, default 500.

  • NmaxDist when n >NmaxDist only the maxknn first neighbours are used for distance compution, default 5000

  • verbose verbose mode, default FALSE.

Value

MGWRSAR returns an object of class mgwrsar with at least the following components:

Betav

matrix of coefficients of dim(n,kv) x kv.

Betac

vector of coefficients of length kc.

Model

The sum of square residuals.

Y

The dependent variable.

XC

The explanatory variables with constant coefficients.

XV

The explanatory variables with varying coefficients.

X

The explanatory variables.

W

The spatial weight matrix for spatial dependence.

isgcv

if gcv has been computed.

edf

The estimated degrees of freedom.

formula

The formula.

data

The dataframe used for computation.

Method

The type of model.

coord

The spatial coordinates of observations.

H

The bandwidth vector.

fixed_vars

The names of constant coefficients.

kernels

The kernel vector.

SSR

The sum of square residuals.

residuals

The vector of residuals.

fit

the vector of fitted values.

sev

local standard error of parameters.

NN

Maximum number of neighbors for weights computation

MGWRSAR is is a wrapper function for estimating linear and local linear model with spatial autocorrelation that allows to estimate the following models : y=\beta_c X_c+\,\epsilon_i (OLS)

y=\beta_v(u_i,v_i) X_v+\,\epsilon_i (GWR)

y=\beta_c X_c+\beta_v(u_i,v_i) X_v+\,\epsilon_i (MGWR)

y=\lambda Wy+\beta_c X_c+\,\epsilon_i (MGWR-SAR(0,k,0))

y=\lambda Wy+\beta_v(u_i,v_i)X_v+\,\epsilon_i (MGWR-SAR(0,0,k))

y=\lambda Wy+\beta_c X_c+\beta_v(u_i,v_i)X_v+\,\epsilon_i (MGWR-SAR(0,k_c,k_v))

y=\lambda(u_i,v_i) Wy+\beta_c X_c+\,\epsilon_i (MGWR-SAR(1,k,0))

y=\lambda(u_i,v_i)Wy+\beta_v(u_i,v_i)X_v+\,\epsilon_i (MGWR-SAR(1,0,k))

y=\lambda(u_i,v_i)Wy+\beta_cX_c+\beta_v(u_i,v_i)X_v+\,\epsilon_i (MGWR-SAR(1,k_c,k_v))

When model imply spatial autocorrelation, a row normalized spatial weight matrix must be provided. 2SLS and Best 2SLS method can be used. When model imply local regression, a bandwidth and a kernel type must be provided. Optimal bandwidth can be estimated using bandwidths_mgwrsar function. When model imply mixed local regression, the names of stationary covariates must be provided.

#' In addition to the ability of considering spatial autocorrelation in GWR/MGWR like models, MGWRSAR function introduces several useful technics for estimating local regression with space coordinates:

  • it uses RCCP and RCCPeigen code that speed up computation and allows parallel computing via doMC package;

  • it allows to drop out variables with not enough local variance in local regression, which allows to consider dummies in GWR/MGWR framework without trouble.

  • it allows to drop out local outliers in local regression.

  • it allows to consider additional variable for kernel, including time (asymetric kernel) and categorical variables (see Li and Racine 2010). Experimental version.

References

Geniaux, G. and Martinetti, D. (2017). A new method for dealing simultaneously with spatial autocorrelation and spatial heterogeneity in regression models. Regional Science and Urban Economics. (https://doi.org/10.1016/j.regsciurbeco.2017.04.001)

McMillen, D. and Soppelsa, M. E. (2015). A conditionally parametric probit model of microdata land use in chicago. Journal of Regional Science, 55(3):391-415.

Loader, C. (1999). Local regression and likelihood, volume 47. springer New York.

Franke, R. and Nielson, G. (1980). Smooth interpolation of large sets of scattered data. International journal for numerical methods in engineering, 15(11):1691-1704.

See Also

bandwidths_mgwrsar, summary_mgwrsar, plot_mgwrsar, predict_mgwrsar, kernel_matW

Examples


 library(mgwrsar)
 ## loading data example
 data(mydata)
 coord=as.matrix(mydata[,c("x_lat","y_lon")])
 ## Creating a spatial weight matrix (sparce dgCMatrix)
 ## of 4 nearest neighbors with 0 in diagonal
 W=kernel_matW(H=4,kernels='rectangle',coord_i=coord,NN=4,adaptive=TRUE,
 diagnull=TRUE,rowNorm=TRUE)
 mgwrsar_0_kc_kv<-MGWRSAR(formula = 'Y_mgwrsar_0_kc_kv~X1+X2+X3', data = mydata,
 coord=coord, fixed_vars='X2',kernels=c('gauss'),H=20, Model = 'MGWRSAR_0_kc_kv',
 control=list(SE=FALSE,adaptive=TRUE,W=W))
 summary_mgwrsar(mgwrsar_0_kc_kv)


mgwrsar documentation built on April 17, 2023, 9:09 a.m.