Sum of Two Objects of Class "spatial.neighbor"

DESCRIPTION:

Function used to calculate sum of two objects of class spatial.neighbor.

USAGE:

spatial.sum(neighbor1, neighbor2, parameters1 = NULL,  
            parameters2 = NULL) 

REQUIRED ARGUMENTS:

neighbor1
object of class "spatial.neighbor" containing the sparse matrix representation of the spatial neighbor matrix (or matrices, see function spatial.neighbor).
neighbor2
object of class "spatial.neighbor" containing the sparse matrix representation of the spatial neighbor matrix (or matrices, see function spatial.neighbor).

OPTIONAL ARGUMENTS:

parameters1
a vector with length equal to the number of weight matrices represented by argument neighbor1. If parameters1 is not specified, a vector of ones is assumed.
parameters2
a vector with length equal to the number of weight matrices represented by argument neighbor2. If parameters2 is not specified, a vector of ones is assumed.

VALUE:

an object of type spatial.neighbor which equals the sum of the two input objects of spatial neighbor.

DETAILS:

Argument neighbor is a sparse matrix representation of one or more matrices using to indicate the strength of "neighbor" relationships for between regions on a spatial grid. Let a[i,j] denote the "(i,j)" element of the k-th such matrix. Then if a[i,j] is not zero, regions i and j are neighbors of the k-th kind, and the strength of the relationship is given by the magnitude of a[i,j]. spatial.weights computes a weighted sum of the matrices A, where the weights in the linear combination are given by the elements in argument parameters.

SEE ALSO:

, .

EXAMPLES:

row.id <- c(1,1,2,2,3) 
col.id <- c(2,3,1,3,4) 
neighbor1 <- spatial.neighbor(row.id=row.id, col.id=col.id) 
col.id <- c(1,2,3,4,1) 
neighbor2 <- spatial.neighbor(row.id=row.id, col.id=col.id) 
print(spatial.weights(neighbor1)) 
print(spatial.weights(neighbor2)) 
a <- spatial.sum(neighbor1,neighbor2) 
print(spatial.weights(a))