Questions tagged [spdep]

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

62 questions
0
votes
1 answer

global moran in spdep package in R

In function moran in spdep package, which argument is being related to the weight matrix (or distance matrix)? moran(x, listw, n, S0, zero.policy=NULL, NAOK=FALSE) I have a matrix W2 which is the distance between some cities, I would like to know…
Rojer
  • 335
  • 2
  • 9
0
votes
1 answer

Error message when using the function autocov_dist from spdep package

I'm using the function autocov_dist from spdep package to estimate the aucovariate. I'm using inverse distance as a weight. When I tested it on my data I got this error message: Error in autocov_dist(Var, xy, nbs = 100, style = "B", type =…
user1988
  • 29
  • 1
  • 7
0
votes
1 answer

Getting different test results between Moran.I and moran.test

I tried to run Moran's I test for the spatial autocorrelation test by using the function Moran.Ifrom the package ape and moran.test from the package spdep I got different results by applying the two methods on the same data. So at this point why…
user1988
  • 29
  • 1
  • 7
0
votes
1 answer

Neighboring Zipcodes from State Polygons

First time posting on SO I have a shapefile that has the geometries for each Zipcode along with state name. I want to figure out which zipcodes lie on the state borders. The way I figured to achieve this is by combining all zipcodes for each state…
0
votes
1 answer

parallelizing function poly2nb {spdep}

The documentation for spdep::poly2nb contains the following entry under Arguments: foundInBox: default NULL using R code, possibly parallelised if a snow cluster is available, otherwise a list of length (n-1) with integer vectors of candidate…
0
votes
2 answers

Generate Neighbour List object for spatial lines in R

My goal is to generate an object of neighbourhood relationships between spatial lines in a road network. If my data were spatial polygons I could use spdep::poly2nb to do this, but I'm having trouble working out how to do this for spatial lines. In…
mark
  • 537
  • 6
  • 25
0
votes
0 answers

all adjustment methods result in same adjusted P values in localmoran() from spdep

I am using localmoran from spdep, which adjusts p values for multiple comparisons based on p.adjustSP. I want to use the holm correction, but I'm not sure if something is wrong as I noticed that whether I specify holm, bonferroni, or hochberg, it…
pbandj
  • 11
  • 1
0
votes
1 answer

Rasterizing Spdep's localG output

I'm reasonably new to R and I am trying to rasterize the output of spdep's localG function. This code: neigh2<-dnearneigh(profcurvPts, 0, 2) list<-nb2listw(neigh2) gistar<-localG(profcurvPts$layer, list) girast<-rasterize(gistar, profcurv) Yields…
Jim Young
  • 3
  • 4
0
votes
1 answer

How to solve "impacts()" neighbors length error after running spdep::lagsarlm (Spatial Autoregressive Regression model)?

I have 9,150 polygons in my dataset. I was trying to run a spatial autoregressive model (SAR) in spdep to test spatial dependence of my outcome variable. After running the model, I wanted to examine the direct/indirect impacts, but encountered an…
Denys D.
  • 11
  • 3
0
votes
1 answer

GAM with MRF smoother: create neighbourhood structure with duplicate coordinates

I want to use the mgcv package in R to run the model df <- as.data.frame(spdf) mod <- gam(y ~ s(geoid, bs = 'mrf', xt = list(nb = nb), k = 20) + s(month, bs = 'cc', k = 12), data = df, method =…
user3036416
  • 1,205
  • 2
  • 15
  • 28
0
votes
1 answer

execution time spatial models in r

I have a problem regarding to the execution time of a SAR model with the 'spdep' package. I pass two different dataset of the same dimension to the same function, it takes very different times (a few seconds vs hours). I write to you my code, if you…
Chiara
  • 1
0
votes
1 answer

How to calculate local autocorrelation via Geary's C in R?

Calculating local autocorrelation via Moran's I is easy with the localmoran() function from the package spdep. But is it possible to calculate Geary's coefficient for local autocorrelation in R? I know that this is possible in GeoDa, but I have no…
0
votes
1 answer

Extract spatial ids from weights list object, spdep R

I have used mat2listw{spdep} to create a weights list object that I will later use in a spatial regression. I would like to retrieve from this weights list object the ids of the polygons used to create it. Is it possible to recover this info from…
rafa.pereira
  • 13,251
  • 6
  • 71
  • 109
0
votes
1 answer

How to input dissimilarity matrix in spatial analysis in spdep R

Aim: I want to create a dissimilarity matrix between pairs of coordinates. I want to use this matrix as an input to calculate local spatial clusters using Moran's I (LISA) and latter in geographically weighted regression (GWR). Problem: I know I can…
rafa.pereira
  • 13,251
  • 6
  • 71
  • 109
0
votes
1 answer

Spatial correlogram

I am trying to run a spatial auto correlogram for a project looking at deforestation in the Atlantic forest, Brazil. I am however confused as to why I am hitting this problem. Problem When I run the initial part of my code i receive an error of…
Guy Benett
  • 23
  • 8