View source: R/spatial_weights.R
spatial_smoother | R Documentation |
This function computes the spatial smoother matrix for a given coordinate matrix using specified parameters.
spatial_smoother(
coord_mat,
sigma = 5,
nnk = 3^(ncol(coord_mat)),
stochastic = TRUE
)
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) |
A sparse symmetric matrix representing the computed spatial smoother
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.