Question spdep package - extending nb object

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

Question spdep package - extending nb object

R-sig-geo mailing list
Dear all,

I am working on a spatial regression model which is built in such a way that the dependent variable consists of n blocks of multiple entries, and each block is referring to the same spatial grid. In order to run the lagsarlm() function or the errsarlm() function, I now need to extend my initial nb object from one grid to n grids. In other words, I need the nb object to be repeated n times. However, so far I did not find a way to do this properly.

I tried to just replicate the nb object by repeating the entries of the neighbours list and the weights list, respectively.

dnn800_3w$neighbours <- rep(dnn800_3w$neighbours,20)
dnn800_3w$weights <- rep(dnn800_3w$weights,20)

When I do this, I get the following error message:

Error in is.symmetric.nb(listw$neighbours, FALSE) : Not neighbours list

Which makes sense, as the matrix is not symmetric any more due to the steps described above. However, I cannot think of a correct implementation at the moment.

Can you help me with this issue? Any suggestions are highly appreciated.

Thank you in advance.

Best regards,

Raphael Mesaric
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Question spdep package - extending nb object

Roger Bivand
Administrator
On Thu, 16 May 2019, Raphael Mesaric via R-sig-Geo wrote:

> Dear all,
>
> I am working on a spatial regression model which is built in such a way
> that the dependent variable consists of n blocks of multiple entries,
> and each block is referring to the same spatial grid. In order to run
> the lagsarlm() function or the errsarlm() function, I now need to extend
> my initial nb object from one grid to n grids. In other words, I need
> the nb object to be repeated n times. However, so far I did not find a
> way to do this properly.
>
> I tried to just replicate the nb object by repeating the entries of the
> neighbours list and the weights list, respectively.
>
> dnn800_3w$neighbours <- rep(dnn800_3w$neighbours,20)
> dnn800_3w$weights <- rep(dnn800_3w$weights,20)
>
> When I do this, I get the following error message:
>
> Error in is.symmetric.nb(listw$neighbours, FALSE) : Not neighbours list
>
> Which makes sense, as the matrix is not symmetric any more due to the
> steps described above. However, I cannot think of a correct
> implementation at the moment.

Not even worth trying, as you found. Do you mean a Kronecker product, as
found in spatial panel models? Or do you mean that you have blocks of
observations without position that belong to upper-level objects with
known position (postcodes or similar)? If the latter, look at
?spdep::nb2blocknb.

Hope this clarifies,

Roger

>
> Can you help me with this issue? Any suggestions are highly appreciated.
>
> Thank you in advance.
>
> Best regards,
>
> Raphael Mesaric
> [[alternative HTML version deleted]]
>
> _______________________________________________
> 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.
voice: +47 55 95 93 55; e-mail: [hidden email]
https://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: Question spdep package - extending nb object

R-sig-geo mailing list
Dear Roger,

Thank you very much for your reply.

It is kind of a spatial panel model, but I have only one time series. To describe it differently:

The dependent variable consists of twenty blocks with averaged data. Each block is related to one season and one out of five time slots (that is why I have 20 blocks - 4 seasons times 5 time slots). And each block of data refers to the very same grid, i.e. the first entry of the first block corresponds to the same call as the first entry of all the other blocks, the second entries correspond to the second cell etc. The grid is of hectare resolution, i.e. 100 x 100m (one could see this as similar to post codes).

Therefore, nb2blocknb() sounds interesting, even though I do not really have „location-less observations“, but just observations with different attributes (season and time). Would it work if my ‚ID‘ argument is built in such a way that it repeats 19 times the identification tags of the first block? For example:

rep(seq(from = 1, to = m, by = 1),19) , where m is the number of cells in my grid?

Best,

Raphael


> Am 17.05.2019 um 14:13 schrieb Roger Bivand <[hidden email]>:
>
> On Thu, 16 May 2019, Raphael Mesaric via R-sig-Geo wrote:
>
>> Dear all,
>>
>> I am working on a spatial regression model which is built in such a way that the dependent variable consists of n blocks of multiple entries, and each block is referring to the same spatial grid. In order to run the lagsarlm() function or the errsarlm() function, I now need to extend my initial nb object from one grid to n grids. In other words, I need the nb object to be repeated n times. However, so far I did not find a way to do this properly.
>>
>> I tried to just replicate the nb object by repeating the entries of the neighbours list and the weights list, respectively.
>>
>> dnn800_3w$neighbours <- rep(dnn800_3w$neighbours,20)
>> dnn800_3w$weights <- rep(dnn800_3w$weights,20)
>>
>> When I do this, I get the following error message:
>>
>> Error in is.symmetric.nb(listw$neighbours, FALSE) : Not neighbours list
>>
>> Which makes sense, as the matrix is not symmetric any more due to the steps described above. However, I cannot think of a correct implementation at the moment.
>
> Not even worth trying, as you found. Do you mean a Kronecker product, as found in spatial panel models? Or do you mean that you have blocks of observations without position that belong to upper-level objects with known position (postcodes or similar)? If the latter, look at ?spdep::nb2blocknb.
>
> Hope this clarifies,
>
> Roger
>
>>
>> Can you help me with this issue? Any suggestions are highly appreciated.
>>
>> Thank you in advance.
>>
>> Best regards,
>>
>> Raphael Mesaric
>> [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> [hidden email] <mailto:[hidden email]>
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo <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 <tel:+47%2055%2095%2093%2055>; e-mail: [hidden email] <mailto:[hidden email]>
> https://orcid.org/0000-0003-2392-6140 <https://orcid.org/0000-0003-2392-6140>
> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en <https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Question spdep package - extending nb object

Roger Bivand
Administrator
Look at multilevel models, fitting iid and/or mrf to the three regular dimensions. Look at the mixed models literature. Some references in https://doi.org/10.1016/j.spasta.2017.01.002, but there is much more.

Hope this helps,

Roger

Roger Bivand
Norwegian School of Economics
Bergen, Norway



Fra: Raphael Mesaric
Sendt: fredag 17. mai, 14.58
Emne: Re: [R-sig-Geo] Question spdep package - extending nb object
Til: Roger Bivand
Kopi: [hidden email]


Dear Roger,

Thank you very much for your reply.

It is kind of a spatial panel model, but I have only one time series. To describe it differently:

The dependent variable consists of twenty blocks with averaged data. Each block is related to one season and one out of five time slots (that is why I have 20 blocks - 4 seasons times 5 time slots). And each block of data refers to the very same grid, i.e. the first entry of the first block corresponds to the same call as the first entry of all the other blocks, the second entries correspond to the second cell etc. The grid is of hectare resolution, i.e. 100 x 100m (one could see this as similar to post codes).

Therefore, nb2blocknb() sounds interesting, even though I do not really have „location-less observations“, but just observations with different attributes (season and time). Would it work if my ‚ID‘ argument is built in such a way that it repeats 19 times the identification tags of the first block? For example:

rep(seq(from = 1, to = m, by = 1),19) , where m is the number of cells in my grid?

Best,

Raphael


Am 17.05.2019 um 14:13 schrieb Roger Bivand <[hidden email]<mailto:[hidden email]>>:

On Thu, 16 May 2019, Raphael Mesaric via R-sig-Geo wrote:

Dear all,

I am working on a spatial regression model which is built in such a way that the dependent variable consists of n blocks of multiple entries, and each block is referring to the same spatial grid. In order to run the lagsarlm() function or the errsarlm() function, I now need to extend my initial nb object from one grid to n grids. In other words, I need the nb object to be repeated n times. However, so far I did not find a way to do this properly.

I tried to just replicate the nb object by repeating the entries of the neighbours list and the weights list, respectively.

dnn800_3w$neighbours <- rep(dnn800_3w$neighbours,20)
dnn800_3w$weights <- rep(dnn800_3w$weights,20)

When I do this, I get the following error message:

Error in is.symmetric.nb(listw$neighbours, FALSE) : Not neighbours list

Which makes sense, as the matrix is not symmetric any more due to the steps described above. However, I cannot think of a correct implementation at the moment.

Not even worth trying, as you found. Do you mean a Kronecker product, as found in spatial panel models? Or do you mean that you have blocks of observations without position that belong to upper-level objects with known position (postcodes or similar)? If the latter, look at ?spdep::nb2blocknb.

Hope this clarifies,

Roger


Can you help me with this issue? Any suggestions are highly appreciated.

Thank you in advance.

Best regards,

Raphael Mesaric
[[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]<mailto:[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.
voice: +47 55 95 93 55; e-mail: [hidden email]<mailto:[hidden email]>
https://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en




        [[alternative HTML version deleted]]

_______________________________________________
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