Learn R Programming

mgwrsar (version 0.1-1)

KNN: A function that returns a row normalized weight matrix based on k first neighbors, to be documented

Description

A function that returns a row normalized weight matrix based on k first neighbors, to be documented

Usage

KNN(coord,h,diagnull=TRUE,kernel='knn',query=NULL)

Arguments

coord

matrix of coordinates

h

a bandwidth

diagnull

0 on diagonal, default TRUE

kernel

kernel type ('bisq','bisq_knn','gauss','gauss_adapt','knn')

query

an index of neighbors to consider, if NULL all observation are used.

Value

a row nomralized weight dgCmatrix

Examples

Run this code
# NOT RUN {
data(mydata)
coord=as.matrix(mydata[,c("x_lat","y_lon")])
W=KNN(coord,8)
which(W[1,]>0)
W[1,W[1,]>0]
# }

Run the code above in your browser using DataLab