[R] spdep question
Christian Hennig
fm3a004 at math.uni-hamburg.de
Tue May 4 16:36:49 CEST 2004
Dear list,
(also sent to Roger Bivand, but perhaps somebody of you can help me also)
I am trying to use package spdep for fitting an SAR model with errorsarlm.
However, I am not sure how to make a valid nb object out of my
neighborhood. As far as I have seen, there is no documentation for
nb.object.
I have done the following:
class(pschmid$nb) <- "nb"
# pschmid is a prab object as generated from function prabinit, package
# prabclus, and the neighborhood looks as follows:
> unclass(pschmid$nb)
[[1]]
[1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
[[2]]
[1] 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
[[3]]
[1] 1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
(...and so on, a list of 65 integer vectors, up to...)
[[65]]
[1] 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
60 61
[26] 62 63 64
# This looks more or less like the example (cal.gol.nb), apart from some
# attribs which I do not understand, and it is exactly
# how an nb object is described in help(read.gal). But...
> summary(pschmid$nb)
Neighbour list object:
Number of regions: 65
Number of nonzero links: 0
Percentage nonzero weights: 0
Average number of links: 0
65 regions with no links:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
54 55 56 57 58 59 60 61 62 63 64 65
Link number distribution:
0
65
# Why are there no links? Do I understand properly what a link is?
# 1 is a neighbor of 2 and vice versa, so I consider them linked?
Can somebody tell me how to turn my neighborhood into an object errorsarlm
and nb2listw (do I need that?) can handle!
Best,
Christian
***********************************************************************
Christian Hennig
Fachbereich Mathematik-SPST/ZMS, Universitaet Hamburg
hennig at math.uni-hamburg.de, http://www.math.uni-hamburg.de/home/hennig/
#######################################################################
ich empfehle www.boag-online.de
More information about the R-help
mailing list