Use the neighborhood matrices of origins and destinations to derive the up to three neighborhood matrices of the origin-destination pairs:

  • W_d relates to flows starting from the same origin going to neighbors of the destination

  • W_o relates to flows starting from the neighbors of the origin going the same destination

  • W_w relates to flows starting from the neighbors of the origin going the neighbors of the destination

expand_spflow_neighborhood(
  OW,
  DW,
  n_o = nrow(OW),
  n_d = nrow(DW),
  M_indicator = NULL,
  model = "model_9"
)

Arguments

OW

The origin neighborhood matrix

DW

The destination neighborhood matrix

n_o

A numeric indicating the number of origins

n_d

A numeric indicating the number of destinations

M_indicator

A matrix of binary indicators for origin-destination pairs that should be included in the model. When the argument is NULL or when all entries of this matrix are different from zero we consider the Cartesian product of all origins and destinations as OD pairs.

model

A character indicating the model number, that controls different spatial dependence structures should be one of paste0("model_", 1:9). Details are given in the documentation of spflow_control().

Value

A list of at most three (sparse) matrices with names given by c("Wd", "Wo", "Ww").

Author

Lukas Dargel

Examples

expand_spflow_neighborhood(DW = 1-diag(2),OW = 1-diag(2))
#> $Wd
#> 4 x 4 sparse Matrix of class "dgCMatrix"
#>             
#> [1,] . 1 . .
#> [2,] 1 . . .
#> [3,] . . . 1
#> [4,] . . 1 .
#> 
#> $Wo
#> 4 x 4 sparse Matrix of class "dgCMatrix"
#>             
#> [1,] . . 1 .
#> [2,] . . . 1
#> [3,] 1 . . .
#> [4,] . 1 . .
#> 
#> $Ww
#>      [,1] [,2] [,3] [,4]
#> [1,]    0    0    0    1
#> [2,]    0    0    1    0
#> [3,]    0    1    0    0
#> [4,]    1    0    0    0
#>