spatial_smoother: Compute the spatial smoother matrix for a coordinate matrix

View source: R/spatial_weights.R

spatial_smootherR Documentation

Compute the spatial smoother matrix for a coordinate matrix

Description

This function computes the spatial smoother matrix for a given coordinate matrix using specified parameters.

Usage

spatial_smoother(
  coord_mat,
  sigma = 5,
  nnk = 3^(ncol(coord_mat)),
  stochastic = TRUE
)

Arguments

coord_mat

A numeric matrix representing coordinates

sigma

Numeric, the sigma parameter for the Gaussian smoother (default is 5)

nnk

Integer, the number of nearest neighbors for adjacency (default is 3^(ncol(coord_mat)))

stochastic

Logical, whether the adjacency matrix should be doubly stochastic (default is TRUE)

Value

A sparse symmetric matrix representing the computed spatial smoother

Examples

# Create an example coordinate matrix
coord_mat <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 3, ncol = 2)

# Compute the spatial smoother matrix with sigma = 5
result <- spatial_smoother(coord_mat, sigma = 5, nnk = 3^(ncol(coord_mat)), stochastic = TRUE)

coord_mat <- as.matrix(expand.grid(x=1:10, y=1:10))
sm <- spatial_smoother(coord_mat, sigma=3)
sm2 <- spatial_smoother(coord_mat, sigma=6, stochastic=FALSE,nnk=50)

bbuchsbaum/neighborweights documentation built on April 1, 2024, 8:41 p.m.