Skip to content
Prev 28314 / 29559 Next

Question on symmetric for nb2mat

On Wed, 29 Jul 2020, Andrea Gilardi wrote:

            
Do things in steps:

adj <- poly2nb(nc_sids)
is.symmetric.nb(adj, force=TRUE)
# [1] TRUE
W0 <- nb2mat(adj, style = "B")
all(W0 == t(W0))
# [1] TRUE
W <- as(W0, "symmetricMatrix")
isSymmetric(W)
#[1] TRUE
res <- chol(W)
#Error in asMethod(object) : not a positive definite matrix

This step makes little sense - why is it included?

I don't know why coercing to Matrix does not see the matrix as symmetric. 
Or:

lw <- nb2listw(adj, style="B")
library(spatialreg)
W <- as(lw, "CsparseMatrix")
#> isSymmetric(W)
#[1] TRUE

This works and is what you might need:

res <- chol((Diagonal(nrow(W)) - 0.1 * W))

or see ?Matrix::USCounties.

Roger
Not useful, not in thread nor do any answers stay in thread.