Skip to contents

Extract the cost matrix used to compute this model

Usage

costs(sim, ...)

Arguments

sim

a spatial interaction model with a cost matrix

...

additional parameters

Value

the cost matrix

Examples

positions <- matrix(rnorm(10 * 2), ncol = 2)
distances <- as.matrix(dist(positions))
production <- rep(1, 10)
attractiveness <- c(2, rep(1, 9))
model <- static_blvim(distances, production, 1.5, 1, attractiveness)
costs(model) ## should be equal to distances above
#>            1         2         3         4         5         6        7
#> 1  0.0000000 1.6429767 1.9034502 1.5882630 1.6088985 2.6056823 3.964833
#> 2  1.6429767 0.0000000 0.5956065 0.8621991 0.6041955 0.9698448 2.629510
#> 3  1.9034502 0.5956065 0.0000000 1.4575799 0.3184202 0.8915506 2.957350
#> 4  1.5882630 0.8621991 1.4575799 0.0000000 1.4085437 1.5690665 2.379980
#> 5  1.6088985 0.6041955 0.3184202 1.4085437 0.0000000 1.1873513 3.162305
#> 6  2.6056823 0.9698448 0.8915506 1.5690665 1.1873513 0.0000000 2.200627
#> 7  3.9648329 2.6295097 2.9573504 2.3799797 3.1623053 2.2006267 0.000000
#> 8  1.2741599 1.5934943 1.4004018 2.1322481 1.1105178 2.2908437 4.222747
#> 9  3.3554869 2.0844950 1.5436571 2.9131922 1.7759563 1.5299997 3.550510
#> 10 0.4265612 1.6163084 1.7408955 1.7788343 1.4262542 2.5341659 4.109326
#>            8        9        10
#> 1  1.2741599 3.355487 0.4265612
#> 2  1.5934943 2.084495 1.6163084
#> 3  1.4004018 1.543657 1.7408955
#> 4  2.1322481 2.913192 1.7788343
#> 5  1.1105178 1.775956 1.4262542
#> 6  2.2908437 1.530000 2.5341659
#> 7  4.2227470 3.550510 4.1093256
#> 8  0.0000000 2.432778 0.8668501
#> 9  2.4327782 0.000000 3.0962405
#> 10 0.8668501 3.096241 0.0000000
all.equal(costs(model), distances)
#> [1] TRUE