help

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

help

Yalemzewod Gelaw
I am a new student to R learning for spatial analysis. I was hoping someone could help me with the
error message I keep getting when I try to convert the neighbour data to a listw object use the nb2listw()  function.
plot(xw_nbq, coords,add=TRUE,col="red")
> summary(xw_nbq)

Neighbour list object:
Number of regions: 140 
Number of nonzero links: 680 
Percentage nonzero weights: 3.469388 
Average number of links: 4.857143 
2 regions with no links:
3 138
Link number distribution:

 0  1  2  3  4  5  6  7  8  9 
 2  6  4 16 32 35 17 13 13  2 
6 least connected regions:
11 32 57 117 124 137 with 1 link
2 most connected regions:
28 71 with 9 links
​when I try to run nb2listw, i got repated error following the below error message. ​

xlist <- nb2listw(neighbours,glist = NULL,style = "W",zero.policy =TRU)
> summary.listw(xlist) Error in summary.listw(xlist) : regions with no neighbours found, use zero.policy=TRUE
I wonder if someone advises me how to fix the error message from my working directory


Regards, 

Yalem

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Rplot.png (20K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: help

Roger Bivand
Administrator
On Thu, 5 Apr 2018, Yalemzewod Gelaw wrote:

> I am a new student to R learning for spatial analysis. I was hoping someone
> could help me with the
> error message I keep getting when I try to convert the neighbour data to a
> listw object use the nb2listw()  function.
>
> plot(xw_nbq, coords,add=TRUE,col="red")> summary(xw_nbq)
>
>
> Neighbour list object:
> Number of regions: 140
> Number of nonzero links: 680
> Percentage nonzero weights: 3.469388
> Average number of links: 4.857143
> 2 regions with no links:
> 3 138
> Link number distribution:
>
> 0  1  2  3  4  5  6  7  8  9
> 2  6  4 16 32 35 17 13 13  2
> 6 least connected regions:
> 11 32 57 117 124 137 with 1 link
> 2 most connected regions:
> 28 71 with 9 links
>
> ​when I try to run nb2listw, i got repated error following the below error
> message. ​
>
> xlist <- nb2listw(neighbours,glist = NULL,style = "W",zero.policy
> =TRU) > summary.listw(xlist)
> Error in summary.listw(xlist) : regions with no neighbours found, use
> zero.policy=TRUE
Please do not send HTML-formatted messages.

You need to continue using zero.policy=TRUE when using an object created
with no-neighbour observations. You can also set a pre-session global
option using set.ZeroPolicyOption(TRUE), which is checked first in
functions using the zero.policy= argument. set.ZeroPolicyOption(TRUE)
outputs the value of get.ZeroPolicyOption() before making the change.

You should always find out why you have no-neighbour observations. From
your attached image, it looks as though you have a faulty set of polygons,
and have used poly2nb() to find border contiguities. My guess is that the
polygons with no neighbours have borders that almost touch - look at the
snap= argument in poly2nb(). There are also other near-contiguities to be
found - had the input boundaries been line-generalized?

Roger

>
> I wonder if someone advises me how to fix the error message from my working
> directory
> ​
>
>
> *Regards, *
>
> Yalem
>
--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: help

andrewaduff
In reply to this post by Yalemzewod Gelaw
Shouldn't this line be

xlist <- nb2listw(neighbours,glist = NULL,style = "W",zero.policy =TRUE)


instead of


xlist <- nb2listw(neighbours,glist = NULL,style = "W",zero.policy =TRU)

?



On Wed, Apr 4, 2018 at 9:44 PM, Yalemzewod Gelaw <[hidden email]>
wrote:

> I am a new student to R learning for spatial analysis. I was hoping
> someone could help me with the
> error message I keep getting when I try to convert the neighbour data to a
> listw object use the nb2listw()  function.
>
> plot(xw_nbq, coords,add=TRUE,col="red")> summary(xw_nbq)
>
>
> Neighbour list object:
> Number of regions: 140
> Number of nonzero links: 680
> Percentage nonzero weights: 3.469388
> Average number of links: 4.857143
> 2 regions with no links:
> 3 138
> Link number distribution:
>
>  0  1  2  3  4  5  6  7  8  9
>  2  6  4 16 32 35 17 13 13  2
> 6 least connected regions:
> 11 32 57 117 124 137 with 1 link
> 2 most connected regions:
> 28 71 with 9 links
>
> ​when I try to run nb2listw, i got repated error following the below error
> message. ​
>
> xlist <- nb2listw(neighbours,glist = NULL,style = "W",zero.policy =TRU) > summary.listw(xlist)
> Error in summary.listw(xlist) : regions with no neighbours found, use
> zero.policy=TRUE
>
> I wonder if someone advises me how to fix the error message from my
> working directory
> ​
>
>
> *Regards, *
>
> Yalem
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo