Questions tagged [spdep]

An R package to provide functions for spatial regression, dependence, and weighting analysis.

62 questions
11
votes
1 answer

Calculation of Moran's I with 4000 records

I have 4000 records of volume in trees plantation. I need to calculate the Moran's I to the whole plantation. I use ape library because spdep is said to be slower. My code is this: # Modified from…
jlopez
  • 335
  • 2
  • 13
8
votes
3 answers

Create a map of spatial clusters LISA in R

I would like to create a map showing local spatial cluster of a phenomenon, preferably using Local Moran (LISA). In the reproducible example below, I calculate the local moran's index using spdep but I would like to know if there is as simple way to…
rafa.pereira
  • 13,251
  • 6
  • 71
  • 109
7
votes
2 answers

GAM with mrf smooth - errors (mismatch between nb/polys area names and data area names

I am trying to fit Polish local government election results in 2015 following the superb blog by @GavinSimpson. https://www.fromthebottomoftheheap.net/2017/10/19/first-steps-with-mrf-smooths/ I joined my xls data with the shp data using a 6 digit…
Jacek Kotowski
  • 620
  • 16
  • 49
5
votes
0 answers

Spatial Regressions with Panel Data in R

I have a panel dataset with several hundred regions, ~10 years and spatial data for the regions. I created a weight matrix with the spdeppackage (via the standard way, and then, nb2listw). I have, thus, a matrix with weights for each region (in…
Jonathan Old
  • 65
  • 1
  • 5
5
votes
0 answers

K-means clustering of spatially constrained data - skater in spdep package

I want to cluster the codebook from a self-organizing map using k-means clustering. However, given the 'spatial' nature of the data, I want to constrain the clustering so that only contiguous nodes are clustered together. After looking around, I…
msoftrain
  • 1,017
  • 8
  • 23
5
votes
0 answers

Spatial auto-correlation test for binary data in R

I want to test a species' presence / absence records for spatial autocorrelation. My data contain >130,000 grids in GIS and with about 700 species' presence records. I have read that the normal Moran's $I$ can't deal with this kind of data, but…
Archer
  • 63
  • 6
4
votes
3 answers

Map of bivariate spatial correlation in R (bivariate LISA)

I would like to create a map showing the bi-variate spatial correlation between two variables. This could be done either by doing a LISA map of bivariate Moran's I spatial correlation or using the L index proposed by Lee (2001). The bi-variate…
rafa.pereira
  • 13,251
  • 6
  • 71
  • 109
4
votes
1 answer

Spatial Autocorrelation Analysis (Global Moran's I) in R

I have a list of points I want to check for autocorrelation using Moran's I and by dividing area of interest by 4 x 4 quadrats. Now every example I found on Google (e. g. http://www.ats.ucla.edu/stat/r/faq/morans_i.htm) uses some kind of…
lightxx
  • 1,037
  • 2
  • 11
  • 29
3
votes
1 answer

texreg table for impacts of spatial lag model

I am using spdep to run a spatial regression using a Durbin lag model. This type of model returns direct, indirect and total effects for each regression coefficient and their level of significance. Is there an R library like texreg that organizes in…
rafa.pereira
  • 13,251
  • 6
  • 71
  • 109
3
votes
0 answers

r - listing and plotting nearest neighbours using the spdep package

It's my first using the spdep package in R so I was hoping someone could help me with a few things. Let's consider the following points. set.seed(1) loc <- data.frame(id=1:15, x=sample(-10:10,15,replace=TRUE), …
Maria Reyes
  • 369
  • 3
  • 18
2
votes
1 answer

Given a spatial (hexagonal) grid how can I obtain a sample of higher order neighbors?

I would like to "thin" a grid made with sf::st_make_grid and obtain a subset of higher order neighbors. First order neighbors share at least one side, 2nd order neighbors share a side with 1st order neighbors, etc. Here is an…
MihaiV
  • 148
  • 8
2
votes
1 answer

neighbour list with poly2nb() works on 2004 census shapefile but not on 2011

I'm trying to construct neighbours list from polygon list for Lower Layer Super Output Areas (LSOA) in London. I got my shapefiles from the London Datastore, by downloading here:…
Rekarrr
  • 356
  • 3
  • 11
2
votes
1 answer

Standard errors of impacts in a spatial regression lagsarlm

I am using a spatial lag and durbin regression models and I would like to estimate the standard errors of the impacts. Any ideas on how to do this? Reproducible example below using a durbin model # data data(oldcol) # neighbours lists lw <-…
rafa.pereira
  • 13,251
  • 6
  • 71
  • 109
2
votes
2 answers

SLX Model - Spatial Econometrics with panel in R data using splm package and slag function

I need to estimate spatial econometric models with spatial lags of X (SLX) either alone, combined with spatial autoregressive models (SAR) or with spatial error model (SEM). When they are combined, they are called Spatial Durbin Model (SDM) or…
dfamaral
  • 115
  • 1
  • 8
2
votes
1 answer

How to create correct spatial lag variables for a raster in R?

lag.listw creates incorrect spatial lag values when I use the function spdep::cell2nb. I have a raster file and want to create a new raster where each cell has the average value of its neighboring cells (spatial lag value). The code below creates…
eliascis
  • 317
  • 2
  • 10
1
2 3 4 5