An R package to provide functions for spatial regression, dependence, and weighting analysis.
Questions tagged [spdep]
62 questions
2
votes
1 answer
Does mat2listw function in R return a row-standardized spatial weight matrix?
In the discussion in the accepted answer in this question, user3050574 said that:
"... it is my understanding that mat2listw creates a row standardized weight matrix from a matrix that is currently just in binary form."
This is the only place that…

Teng Huang
- 21
- 3
2
votes
1 answer
Weighting observations in a spdep::lagsarlm Model?
I would like to estimate a spdep::lagsarlm Model (Spatially Autoregressive Regression) in R. My observations (n=447) are polygons, each representing an administrative region of Berlin.
However, the problem is that the regions have a highly varying…

chamaoskurumi
- 2,271
- 2
- 23
- 30
2
votes
2 answers
spdep "Not yet able to subset general weights lists" listw
I have a problems with spdep(). Starting with a matrix of non-missing distances produced by a function
dist_m <- geoDistMatrix(data1, group = 'fips_dist')
dist_m[upper.tri(dist_m)] <- t(dist_m)[upper.tri(dist_m)]
we then turn into weights with…

JLM
- 21
- 4
1
vote
1 answer
manually fixing colors in the map
The data is:
d.fit.spatial.1914 <- structure(list(country = c("Albania", "Austria", "Belgium", "Netherlands",
"Poland", "Portugal", "Denmark", "Germany", "Greece", "Spain",
"Bulgaria", "Switzerland",…

Rustam
- 87
- 6
1
vote
0 answers
no 'nobs' method available: Using the MuMIn package with simultaneous autoregression models
I'm hoping someone can help me figure out why the MuMIn package is not working with my simultaneous autoregression models. I have double checked the documentation for the package and it lists sarlm as one of the supported model types. However, when…

Kristin
- 11
- 1
1
vote
1 answer
Robust Standard Errors in spatial error models
I am fitting a Spatial Error Model using the errorsarlm() function in the spdep library.
The Breusch-Pagan test for spatial models, calculated using the bptest.sarlm() function, suggest the presence of heteroskedasticity.
A natural next step would…

Orlando Sabogal
- 1,470
- 7
- 20
1
vote
1 answer
Converting a normal list into a nb/spdep object in R?
I need to create a neighbours list from a spatial polygon. At the moment i am using the function poly2nb, but unfortunately it is not very accurate, and some polygons with no common points are considered neighbours. I have tried changing the snap…

mrc
- 11
- 1
1
vote
1 answer
Include ID in an spatial weight matrix R
I have a data frame like this one:
dataSp <- read.table( text = '
ID LATITUDE LONGITUDE
A -85 134
B 34 2
C 42 3
D 45 5
E -2 80
F -5 …

Lilia
- 109
- 8
1
vote
0 answers
Creating a giant matrix for use in CARBayes without running out of memory
I am trying to do an areal unit analysis using the package CARBayes. As part of the analysis, I am using the below code. my issue comes when I try to create the neighbour matrix with nb2mat. My sp object has 170,000 odd polygons in it so it can't…

hclutter
- 11
- 5
1
vote
0 answers
How to estimate SAR spatial model without row-normalizing the matrix?
I am trying to estimate a SAR spatial model without row-normalizing the matrix. For some reason, when I do not row-normalize, the command does not return the correct estimates. Am I missing something on the command options?
Here is an example of…

Miranda
- 148
- 13
1
vote
1 answer
How to estimate spatial SAR model with islands?
I am trying to estimate a spatial SAR model using the lagsarlm command and I get the following error:
Error in lagsarlm(f1, data = df, spatialList, tol.solve = 1e-30) :
NAs in lagged dependent variable
In addition: Warning message:
…

Miranda
- 148
- 13
1
vote
2 answers
Plotting graphs from class `nb` - How to change points color?
It is easier to explain what am I trying to do through the following reproducible example:
library(sf)
library(brazilmaps)
library(spdep)
# loading cities map
cities_mg <- brazilmaps::get_brmap(geo = 'City',
…

lcgodoy
- 763
- 5
- 14
1
vote
0 answers
Compute distance based Local Moran for 527k+ point dataset using spdep library
As the title says, I'm trying to compute Local Moran for a 527k point dataset using the spdep package, creating neighborhoods based on distance. The generalized process I'm doing is the following:
library(spdep)
# Convert coordinates to…

Arodas
- 11
- 1
1
vote
2 answers
Problems updating packages igraph and spdep
I´m trying to install the package NormqPCR and I have to update two packages, igraph and spdep, but until now I couldn´t and I can´t figure out what I must supouse to do.
This is the code.
if (!requireNamespace("BiocManager", quietly = TRUE))
+ …

Gerardo Irigoyen
- 13
- 2
1
vote
0 answers
How to optimize finding trace of a square matrix multiplication?
I'm trying to optimize spdep function of R for my use case since it is very slow for large databases. I was doing mostly fine but I stuck at one point, where I am trying to find trace of my weights matrix for LM error test. I think the formula is…

orcmor
- 13
- 3