Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling no-neighbour observations and sub-graphs in spdep #62

Open
rsbivand opened this issue Nov 9, 2023 · 8 comments
Open

Handling no-neighbour observations and sub-graphs in spdep #62

rsbivand opened this issue Nov 9, 2023 · 8 comments

Comments

@rsbivand
Copy link
Member

rsbivand commented Nov 9, 2023

https://stat.ethz.ch/pipermail/r-sig-geo/2023-November/029353.html:

In forthcoming spdep 1.3-1, spatial weight listw objects get a new zero.policy attribute. The attribute is added as objects are created to record the status of the zero.policy argument in the function creating the object, see: r-spatial/spdep@e159de9.

Reverse dependency checks only show problems from over-eager unit testing in SpatialFeatureExperiment, a Bioconductor package, but other workflows may be impacted. The new attribute is used in tests for spatial autocorrelation to set the zero.policy argument in those tests (the arguments were zero.policy=NULL, are now zero.policy=attr(listw, "zero.policy") where listw is the spatial weights object argument to the test function.

This will be extended to spatialreg and friends if nobody reports negative impacts here soon. I'll wait before releasing 1.3-1 for a few days to see if any feedback is forthcoming.

https://stat.ethz.ch/pipermail/r-sig-geo/2023-November/029354.html

And a question: in nb2listw() and similar functions creating spatial weights listw objects, would it be sensible to guess that the presence of no-neighbour observations in the input nb neighbour implies the choice of a spatially lagged value of zero (zero.policy=TRUE), lx = Wx, rather than NA (zero.policy=FALSE)?

That is, use by default zero.policy=any(card(nb) == 0L) rather than zero.policy=NULL and look in the spdep option set by default on package load to FALSE but settable by the user?

Would this be taking trying to be helpful too far, given that the analyst is creating the neighbour object and presumably should take responsibility for choices made?

Context: polygons not sharing boundaries with other polygons do exist legitimately in data sources, but setting spatially lagged values to zero for those polygons is quite an invasive imputation. It may be better to oblige the user to make the choice when the spatial weights listw object is created.

Little is known about the problem, for a recent treatment for CAR models see: https://arxiv.org/abs/1705.04854, published as https://doi.org/10.1016/j.sste.2018.04.002, where: "The specification of a CAR model on a disconnected graph is undefined ... [t]here are essentially two types of disconnected graphs: first, a graph containing an island (a singleton node with no neighbours), second, a graph split in different sub-graphs (each of them being a connected graph)".

This question concerns the former, singleton, case, but adding sub-graph counts if greater than unity to summary.nb and print.nb address the second . Very possibly, functions creating nb neighbour objects should themselves report that an output object (graph) is not connected, bigDM CARBayes CARBayesST geostan spatialreg stampr do call spdep::n.comp.nb themselves to check the subgraph count.

@rsbivand
Copy link
Member Author

rsbivand commented Nov 9, 2023

@gpiras @JosiahParry @ConnorDonegan - I'll follow up on R-sig-geo, pointing to this issue.

@rsbivand
Copy link
Member Author

rsbivand commented Nov 17, 2023

@LukeCe : I think I saw use of spdep::mat2listw in today's talk, but don't see it in the current package repository, so maybe I was wrong. If however it was used, please note that there are changes in progress in this and related functions.

@LukeCe
Copy link

LukeCe commented Nov 22, 2023

I only use some spdep functions ending on 2nb in the spflow package.
I will keep an eye on the changes to these functions, thanks for your message anyway.

rsbivand added a commit to r-spatial/spdep that referenced this issue Nov 22, 2023
@rsbivand
Copy link
Member Author

spdep 1.3-1 submitted to CRAN.

rsbivand added a commit to r-spatial/spatialreg that referenced this issue Nov 22, 2023
@JosiahParry
Copy link

Good luck!

@rsbivand
Copy link
Member Author

spdep 1.3-1 published on CRAN, will submit spatialreg 1.3-1 shortly.

@rsbivand
Copy link
Member Author

spatialreg_1.3-1.tar.gz is on its way to CRAN

sdray added a commit to adeverse/adespatial that referenced this issue Jan 11, 2024
The usage of mat2listw has been modified by R. Bivand (r-spatial/discuss#62) as a new zero.policy attribute has been added
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants