[R-sig-Geo] Question on symmetric for nb2mat

Andrea Gilardi @@g||@rd|5 @end|ng |rom c@mpu@@un|m|b@|t
Wed Jul 29 17:32:00 CEST 2020


Dear all, I think the following message should work. Excuse me for the
previous message.

library(spdep)
library(rgdal)
library(Matrix)

nc_sids <- readOGR(system.file("shapes/sids.shp", package = "spData"))
adj <- poly2nb(nc_sids)
W <- as(nb2mat(adj, style = "B"), "Matrix")
Matrix::isSymmetric(W)
chol(W)

If it's still not working I added a reprex here:
https://gist.github.com/agila5/59d3a173df9b1efabe13800f748a2d48

Kind regards
Andrea


Il giorno mer 29 lug 2020 alle ore 17:19 Roger Bivand <Roger.Bivand using nhh.no>
ha scritto:

> Please follow-up in this thread posting in plain text (not HTML). As you
> can see below, HTML garbles your message.
>
> On Wed, 29 Jul 2020, Andrea Gilardi wrote:
>
> > Dear all, probably I'm missing something obvious but I have a question on
> > the matrix built using nb2mat with argument style = "B". More precisely,
> I
> > don't understand why the following code says that the matrix *W* (which
> > should be a binary first-order adjacency matrix) is not symmetric:
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > *library(spdep)library(rgdal)library(Matrix)# datanc.sids <-
> > readOGR(system.file("shapes/sids.shp", package = "spData"))adj <-
> > poly2nb(nc.sids)W <- as(nb2mat(adj, style = "B"),
> > "Matrix")Matrix::isSymmetric(W)#> [1] FALSEchol(W)#> Error in
> > asMethod(object): not a symmetric matrix; consider forceSymmetric() or
> > symmpart()*
> >
> > Kind regards
> > Andrea
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo using r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
> --
> Roger Bivand
> Department of Economics, Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; e-mail: Roger.Bivand using nhh.no
> https://orcid.org/0000-0003-2392-6140
> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list