Learn R Programming

mgwrsar (version 1.1)

kernel_matW: kernel_matW A function that returns a sparse weight matrix based computed with a specified kernel (gauss,bisq,tcub,epane,rectangle,triangle) considering coordinates provides in S and a given bandwidth. If NN<nrow(S) only NN firts neighbours are considered. If Type!='GD' then S should have additional columns and several kernels and bandwidths should be be specified by the user.

Description

kernel_matW A function that returns a sparse weight matrix based computed with a specified kernel (gauss,bisq,tcub,epane,rectangle,triangle) considering coordinates provides in S and a given bandwidth. If NN<nrow(S) only NN firts neighbours are considered. If Type!='GD' then S should have additional columns and several kernels and bandwidths should be be specified by the user.

Usage

kernel_matW(H,kernels,coords,NN,TP=NULL,Type='GD',adaptive=FALSE,
diagnull=TRUE,alpha=1,theta=1,dists=NULL,indexG=NULL,extrapol=FALSE,QP=NULL,K=0)

Value

A sparse Matrix of weights (dgCMatrix).

Arguments

H

A vector of bandwidths

kernels

A vector of kernel types

coords

A matrix with variables used in kernel (reference)

NN

Number of spatial Neighbours for kernels computations

TP

A vector with index of target points

Type

Type of Genelarized kernel product ('GD' only spatial,'GDC' spatial + a categorical variable,'GDX' spatial + a continuous variable, 'GDT' spatial + a time index, and other combinations 'GDXXC','GDTX',...)

adaptive

A vector of boolean to choose adaptive version for each kernel

diagnull

Zero on diagonal, default FALSE

alpha

TO BE DOCUMENTED

theta

TO BE DOCUMENTED

dists

TO BE DOCUMENTED

indexG

TO BE DOCUMENTED

extrapol

TO BE DOCUMENTED

QP

A matrix with variables used in kernel (neighbors), default NULL (if NULL coord_j=coord_i)

K

TO BE DOCUMENTED

Examples

Run this code
# \donttest{
 library(mgwrsar)
 ## loading data example
 data(mydata)
 coords=as.matrix(mydata[,c("x","y")])
 ## Creating a spatial weight matrix (sparce dgCMatrix) of 4 nearest neighbors with 0 in diagonal
 W=kernel_matW(H=4,kernels='rectangle',coords=coords,NN=4,adaptive=TRUE,diagnull=TRUE)
# }

Run the code above in your browser using DataLab