Package: spdep 1.4-3

Roger Bivand

spdep: Spatial Dependence: Weighting Schemes, Statistics

A collection of functions to create spatial weights matrix objects from polygon 'contiguities', from point patterns by distance and tessellations, for summarizing these objects, and for permitting their use in spatial data analysis, including regional aggregation by minimum spanning tree; a collection of tests for spatial 'autocorrelation', including global 'Morans I' and 'Gearys C' proposed by 'Cliff' and 'Ord' (1973, ISBN: 0850860369) and (1981, ISBN: 0850860814), 'Hubert/Mantel' general cross product statistic, Empirical Bayes estimates and 'Assunção/Reis' (1999) <doi:10.1002/(SICI)1097-0258(19990830)18:16%3C2147::AID-SIM179%3E3.0.CO;2-I> Index, 'Getis/Ord' G ('Getis' and 'Ord' 1992) <doi:10.1111/j.1538-4632.1992.tb00261.x> and multicoloured join count statistics, 'APLE' ('Li et al.' ) <doi:10.1111/j.1538-4632.2007.00708.x>, local 'Moran's I', 'Gearys C' ('Anselin' 1995) <doi:10.1111/j.1538-4632.1995.tb00338.x> and 'Getis/Ord' G ('Ord' and 'Getis' 1995) <doi:10.1111/j.1538-4632.1995.tb00912.x>, 'saddlepoint' approximations ('Tiefelsdorf' 2002) <doi:10.1111/j.1538-4632.2002.tb01084.x> and exact tests for global and local 'Moran's I' ('Bivand et al.' 2009) <doi:10.1016/j.csda.2008.07.021> and 'LOSH' local indicators of spatial heteroscedasticity ('Ord' and 'Getis') <doi:10.1007/s00168-011-0492-y>. The implementation of most of these measures is described in 'Bivand' and 'Wong' (2018) <doi:10.1007/s11749-018-0599-x>, with further extensions in 'Bivand' (2022) <doi:10.1111/gean.12319>. 'Lagrange' multiplier tests for spatial dependence in linear models are provided ('Anselin et al'. 1996) <doi:10.1016/0166-0462(95)02111-6>, as are 'Rao' score tests for hypothesised spatial 'Durbin' models based on linear models ('Koley' and 'Bera' 2023) <doi:10.1080/17421772.2023.2256810>. Additions in 2024 include Local Indicators for Categorical Data based on 'Carrer et al.' (2021) <doi:10.1016/j.jas.2020.105306> and 'Bivand et al.' (2017) <doi:10.1016/j.spasta.2017.03.003>; also Weighted Multivariate Spatial Autocorrelation Measures ('Bavaud' 2024) <doi:10.1111/gean.12390>. <doi:10.1080/17421772.2023.2256810>. A local indicators for categorical data (LICD) implementation based on 'Carrer et al.' (2021) <doi:10.1016/j.jas.2020.105306> and 'Bivand et al.' (2017) <doi:10.1016/j.spasta.2017.03.003> was added in 1.3-7. Multivariate 'spatialdelta' ('Bavaud' 2024) <doi:10.1111/gean.12390> was added in 1.3-13 ('Bivand' 2025 <doi:10.26034/la.cdclsl.2025.8343>). 'Moran' scatterplot enhancements were contributed by 'René' 'Westerholt' in 1.4-3 <doi:10.5281/zenodo.10897792>. From 'spdep' and 'spatialreg' versions >= 1.2-1, the model fitting functions previously present in this package are defunct in 'spdep' and may be found in 'spatialreg'.

Authors:Roger Bivand [cre, aut], Micah Altman [ctb], Luc Anselin [ctb], Renato Assunção [ctb], Anil Bera [ctb], Olaf Berke [ctb], F. Guillaume Blanchet [ctb], Marilia Carvalho [ctb], Bjarke Christensen [ctb], Yongwan Chun [ctb], Carsten Dormann [ctb], Stéphane Dray [ctb], Dewey Dunnington [ctb], Virgilio Gómez-Rubio [ctb], Malabika Koley [ctb], Tomasz Kossowski [ctb], Elias Krainski [ctb], Pierre Legendre [ctb], Nicholas Lewin-Koh [ctb], Angela Li [ctb], Giovanni Millo [ctb], Werner Mueller [ctb], Hisaji Ono [ctb], Josiah Parry [ctb], Pedro Peres-Neto [ctb], Michał Pietrzak [ctb], Gianfranco Piras [ctb], Markus Reder [ctb], Jeff Sauer [ctb], Michael Tiefelsdorf [ctb], René Westerholt [ctb], Justyna Wilk [ctb], Levi Wolf [ctb], Danlin Yu [ctb]

spdep_1.4-3.tar.gz
spdep_1.4-3.zip(r-4.7)spdep_1.4-3.zip(r-4.6)spdep_1.4-3.zip(r-4.5)
spdep_1.4-3.tgz(r-4.6-x86_64)spdep_1.4-3.tgz(r-4.6-arm64)spdep_1.4-3.tgz(r-4.5-x86_64)spdep_1.4-3.tgz(r-4.5-arm64)
spdep_1.4-3.tar.gz(r-4.7-arm64)spdep_1.4-3.tar.gz(r-4.7-x86_64)spdep_1.4-3.tar.gz(r-4.6-arm64)spdep_1.4-3.tar.gz(r-4.6-x86_64)
spdep_1.4-3.tgz(r-4.6-emscripten)
manual.pdf |manual.html
card.svg |card.png
spdep/json (API)
NEWS

# Install 'spdep' in R:
install.packages('spdep', repos = c('https://r-spatial.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/r-spatial/spdep/issues

Pkgdown/docs site:https://r-spatial.github.io

Datasets:
  • bbs - Columbus OH spatial analysis data set
  • col.gal.nb - Columbus OH spatial analysis data set
  • COL.nb - Columbus OH spatial analysis data set - old numbering
  • COL.OLD - Columbus OH spatial analysis data set - old numbering
  • columbus - Columbus OH spatial analysis data set
  • coords - Columbus OH spatial analysis data set
  • eire.coords.utm - Eire data sets
  • eire.df - Eire data sets
  • eire.nb - Eire data sets
  • eire.polys.utm - Eire data sets
  • polys - Columbus OH spatial analysis data set

On CRAN:

Conda:

spatial-autocorrelationspatial-dependencespatial-weights

17.19 score 148 stars 138 packages 11k scripts 70k downloads 233 mentions 184 exports 17 dependencies

Last updated from:c1a3e68a96. Checks:13 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK227
linux-devel-x86_64OK255
source / vignettesOK324
linux-release-arm64OK230
linux-release-x86_64OK237
macos-release-arm64OK154
macos-release-x86_64OK606
macos-oldrel-arm64OK161
macos-oldrel-x86_64OK416
windows-develOK218
windows-releaseOK197
windows-oldrelOK214
wasm-releaseOK175

Exports:addlinks1aggregate.nbairdistas.data.frame.localmoranexas.data.frame.localmoransadautocov_distcardcell2nbchkIDschoynowskicoercecomplement.nbcornish_fisherdf2sndiffnbdnearneighdroplinksEBestEBImoran.mcEBlocaledit.nbfactorial_coordinatesgabrielneighgearygeary.mcgeary.testget.ClusterOptionget.coresOptionget.mcOptionget.NoNeighbourOptionget.spChkOptionget.SubgraphCeilingget.SubgraphOptionget.VerboseOptionget.ZeroPolicyOptionglobalG.testgraph_distance_weightsgraph2nbgrid2nbhave_factor_preds_mfhotspotinclude.selfintersect.nbis.symmetric.glistis.symmetric.nbiterative_proportional_fitting_weightsjoincount.mcjoincount.multijoincount.testknearneighknn2nblag.listwleelee.mclee.testlicd_multilinearised_diffusive_weightslistw2lineslistw2matlistw2snlistw2starlistw2Ulistw2WBlm.LMtestslm.morantestlm.morantest.exactlm.morantest.sadlm.RStestslocal_joincount_bvlocal_joincount_unilocalClocalC_permlocaldeltalocalGlocalG_permlocalGSlocalmoranlocalmoran_bvlocalmoran_permlocalmoran.exactlocalmoran.exact.altlocalmoran.sadLOSHLOSH.csLOSH.mcmake.sym.nbmat2listwmetropolis_hastings_weightsmoranmoran_bvmoran.mcmoran.plotmoran.plot.dropmoran.plot.seismogrammoran.testmstreen.comp.nbnb2blocknbnb2INLAnb2linesnb2listwnb2listwdistnb2matnb2WBnbcostnbcostsnbdistsnblagnblag_cumulold.make.sym.nbp.adjustSPplot_factorialcoordsplot_factorialscreeplot_moranplot_spatialcoordsplot_spatialscreeplot.Gabrielplot.listwplot.mc.simplot.mstplot.nbplot.relativeplot.skaterplot.spcorpoly2nbprint.jclistprint.jcmultiprint.localmoranexprint.localmoransadprint.moranexprint.moransadprint.spcorprint.summary.localmoransadprint.summary.moransadprobmapprunecostprunemstread_swm_dbfread.dat2listwread.galread.geodaread.gwt2nbread.swmdbf2listwrelativeneighremove.selfRotationSD.RStestsset.ClusterOptionset.coresOptionset.mcOptionset.NoNeighbourOptionset.spChkOptionset.SubgraphCeilingset.SubgraphOptionset.VerboseOptionset.ZeroPolicyOptionsetdiff.nbskatersn2listwsoi.graphsp.correlogramsp.mantel.mcspatialdeltaspdepspNamedVecspweights.constantssswsubset.listwsubset.nbsummary.localmoransadsummary.moransadsym.attr.nbSzerotolerance.nbtri2nbunion.nbvi2mrcwarn_factor_predswrite_swm_dbfwrite.nb.galwrite.sn2datwrite.sn2DBFwrite.sn2gwtwrite.swmdbf

Dependencies:bootclassclassIntDBIdeldire1071KernSmoothlatticeMASSproxyRcpps2sfspspDataunitswk

“The Problem of Spatial Autocorrelation:” forty years on

Rendered fromCO69.Rmdusingknitr::rmarkdownon Jun 01 2026.

Last update: 2025-01-20
Started: 2019-01-09

Creating Neighbours

Rendered fromnb.Rmdusingknitr::rmarkdownon Jun 01 2026.

Last update: 2024-09-07
Started: 2020-11-23

Creating Neighbours using sf objects

Rendered fromnb_sf.Rmdusingknitr::rmarkdownon Jun 01 2026.

Last update: 2025-05-20
Started: 2017-11-01

Introduction to the North Carolina SIDS data set (re-revised)

Rendered fromsids.Rmdusingknitr::rmarkdownon Jun 01 2026.

Last update: 2024-12-02
Started: 2019-01-09

No-neighbour observation and subgraph handling

Rendered fromsubgraphs.Rmdusingknitr::rmarkdownon Jun 01 2026.

Last update: 2025-05-20
Started: 2024-09-06

Readme and manuals

Help Manual

Help pageTopics
Aggregate a spatial neighbours objectaggregate.nb
Measure distance from plotairdist
Distance-weighted autocovariateautocov_dist
Data set with 4 life condition indices of Belo Horizonte regionbhicv
Cardinalities for neighbours listscard
Generate neighbours list for grid cellscell2nb vi2mrc
Choynowski probability map valueschoynowski
Columbus OH spatial analysis data setbbs col.gal.nb columbus coords polys
Differences between neighbours listsdiffnb
Neighbourhood contiguity by distancednearneigh
Drop and add links in a neighbours listaddlinks1 droplinks
Global Empirical Bayes estimatorEBest
Permutation test for empirical Bayes indexEBImoran EBImoran.mc
Local Empirical Bayes estimatorEBlocal
Interactive editing of neighbours listsedit.nb
Eire data setseire eire.coords.utm eire.df eire.nb eire.polys.utm
Compute Geary's Cgeary
Permutation test for Geary's C statisticgeary.mc
Geary's C test for spatial autocorrelationgeary.test
Global G test for spatial autocorrelationglobalG.test
Depth First Search on Neighbor Listsn.comp.nb
Graph based spatial weightsgabrielneigh graph2nb plot.Gabriel plot.relative relativeneigh soi.graph
Construct neighbours for a GridTopologygrid2nb
Cluster Classifications for Local Indicators of Spatial Association and Local Indicators for Categorical Datahotspot hotspot.data.frame.localmoranex hotspot.default hotspot.licd hotspot.localC hotspot.localG hotspot.localmoran hotspot.local_jc_uni hotspot.summary.localmoransad
Include self in neighbours listinclude.self remove.self
Test a neighbours list for symmetryis.symmetric.glist is.symmetric.nb make.sym.nb old.make.sym.nb sym.attr.nb
Permutation test for same colour join count statisticsjoincount.mc
BB, BW and Jtot join count statistic for k-coloured factorsjoincount.multi print.jcmulti
BB join count statistic for k-coloured factorsjoincount.test print.jclist
K nearest neighbours for spatial weightsknearneigh
Neighbours list from knn objectknn2nb
Spatial lag of a numeric vectorlag.listw
Compute Lee's statisticlee
Permutation test for Lee's L statisticlee.mc
Lee's L test for spatial autocorrelationlee.test
Local Indicators for Categorical Datalicd_multi
Spatial neighbour sparse representationlistw2sn sn2listw
Rao's score (a.k.a Lagrange Multiplier) diagnostics for spatial dependence in linear modelslm.LMtests lm.RStests print.RStestlist print.RStestlist.summary summary.RStestlist
Moran's I test for residual spatial autocorrelationlm.morantest
Exact global Moran's I testlm.morantest.exact print.moranex
Saddlepoint approximation of global Moran's I testlm.morantest.sad print.moransad print.summary.moransad summary.moransad
Calculate the local bivariate join countlocal_joincount_bv
Calculate the local univariate join countlocal_joincount_uni
Compute Local Geary statisticlocalC localC.data.frame localC.default localC.formula localC.list localC.matrix localC_perm localC_perm.default localC_perm.formula
G and Gstar local spatial statisticslocalG localG_perm
A local hotspot statistic for analysing multiscale datasetslocalGS
Local Moran's I statisticlocalmoran localmoran_perm
Compute the Local Bivariate Moran's I Statisticlocalmoran_bv
Exact local Moran's Ii testsas.data.frame.localmoranex localmoran.exact localmoran.exact.alt print.localmoranex
Saddlepoint approximation of local Moran's Ii testsas.data.frame.localmoransad listw2star localmoran.sad print.localmoransad print.summary.localmoransad summary.localmoransad
Local spatial heteroscedasticityLOSH
Chi-square based test for local spatial heteroscedasticityLOSH.cs
Bootstrapping-based test for local spatial heteroscedasticityLOSH.mc
Convert a square spatial weights matrix to a weights list objectmat2listw
Compute Moran's Imoran
Compute the Global Bivariate Moran's Imoran_bv
Permutation test for Moran's I statisticmoran.mc
Moran scatterplotmoran.plot
Moran drop plotmoran.plot.drop
Moran seismogrammoran.plot.seismogram
Moran's I test for spatial autocorrelationmoran.test
Find the minimal spanning treemstree
Set operations on neighborhood objectscomplement.nb intersect.nb setdiff.nb union.nb
Block up neighbour list for location-less observationsnb2blocknb
Output spatial neighbours for INLAnb2INLA
Use vector files for import and export of weightsdf2sn listw2lines nb2lines
Spatial weights for neighbours listslistw2U nb2listw
Distance-based spatial weights for neighbours listsnb2listwdist
Spatial weights matrices for neighbours listslistw2mat nb2mat
Output spatial weights for WinBUGSlistw2WB nb2WB
Compute cost of edgesnbcost nbcosts
Spatial link distance measuresnbdists
Higher order neighbours listsnblag nblag_cumul
Columbus OH spatial analysis data set - old numberingCOL.nb COL.OLD oldcol
Adjust local association measures' p-valuesp.adjustSP
Plot the Minimum Spanning Treeplot.mst
Plot a neighbours listplot.listw plot.nb
Plot the object of skater classplot.skater
Construct neighbours list from polygon listpoly2nb
Probability mapping for ratesprobmap
Compute cost of prune each edgeprunecost
Prune a Minimun Spanning Treeprunemst
Read a GAL lattice file into a neighbours listread.gal read.geoda
Read and write spatial neighbour filesread.dat2listw read.gwt2nb read.swmdbf2listw read_swm_dbf write.sn2dat write.sn2DBF write.sn2gwt write.swmdbf write_swm_dbf
Rotate a set of point by a certain angleRotation
Rao's score and adjusted Rao's score tests of linear hypotheses for spatial Durbin and spatial Durbin error modelshave_factor_preds_mf SD.RStests warn_factor_preds
Options for parallel supportget.ClusterOption get.coresOption get.mcOption set.ClusterOption set.coresOption set.mcOption
Control checking of spatial object IDschkIDs get.listw_is_CsparseMatrix_Option get.NoNeighbourOption get.spChkOption get.SubgraphCeiling get.SubgraphOption get.VerboseOption get.ZeroPolicyOption set.listw_is_CsparseMatrix_Option set.NoNeighbourOption set.spChkOption set.SubgraphCeiling set.SubgraphOption set.VerboseOption set.ZeroPolicyOption spNamedVec
Spatial 'K'luster Analysis by Tree Edge Removalskater
Spatial correlogramplot.spcor print.spcor sp.correlogram
Mantel-Hubert spatial general cross product statisticplot.mc.sim sp.mantel.mc
Weighted Multivariate Spatial Autocorrelation Measuresas.matrix.adjusted_spatial_weights cornish_fisher cornish_fisher.default cornish_fisher.spatialdelta factorial_coordinates factorial_coordinates.default factorial_coordinates.spatialdelta graph_distance_weights iterative_proportional_fitting_weights linearised_diffusive_weights localdelta localdelta.default localdelta.spatialdelta metropolis_hastings_weights plot_factorialcoords plot_factorialcoords.default plot_factorialcoords.spatialdelta plot_factorialscree plot_factorialscree.default plot_factorialscree.spatialdelta plot_moran plot_moran.default plot_moran.spatialdelta plot_spatialcoords plot_spatialcoords.default plot_spatialcoords.spatialdelta plot_spatialscree plot_spatialscree.default plot_spatialscree.spatialdelta print.summary.spatialdelta spatialdelta summary.spatialdelta
Return package version numberspdep
Defunct Functions in Package 'spdep'anova.sarlm aple aple.mc aple.plot as.data.frame.sarlm.pred as.spam.listw as_dgRMatrix_listw as_dsCMatrix_I as_dsCMatrix_IrW as_dsTMatrix_listw bptest.sarlm can.be.simmed cheb_setup coef.gmsar coef.lagmess coef.sarlm coef.spautolm coef.stsls coerce,listw,CsparseMatrix-method coerce,listw,RsparseMatrix-method coerce,listw,symmetricMatrix-method create_WX deviance.gmsar deviance.lagmess deviance.sarlm deviance.spautolm deviance.stsls do_ldet eigenw eigen_pre_setup eigen_setup errorsarlm fitted.gmsar fitted.lagmess fitted.ME_res fitted.sarlm fitted.SFResult fitted.spautolm GMargminImage GMerrorsar griffith_sone gstsls Hausman.test Hausman.test.gmsar Hausman.test.sarlm HPDinterval.lagImpact impacts impacts.gmsar impacts.lagmess impacts.MCMC_sac_g impacts.MCMC_sar_g impacts.MCMC_sem_g impacts.sarlm impacts.SLX impacts.stsls intImpacts jacobianSetup Jacobian_W lagmess lagsarlm lextrB lextrS lextrW lmSLX localAple logLik.lagmess logLik.sarlm logLik.spautolm LR.sarlm LR1.sarlm LR1.spautolm LU_prepermutate_setup LU_setup l_max Matrix_J_setup Matrix_setup mcdet_setup MCMCsamp MCMCsamp.sarlm MCMCsamp.spautolm ME moments_setup mom_calc mom_calc_int2 plot.lagImpact powerWeights predict.sarlm predict.SLX print.gmsar print.lagImpact print.lagmess print.ME_res print.sarlm print.sarlm.pred print.SFResult print.spautolm print.stsls print.summary.gmsar print.summary.lagImpact print.summary.lagmess print.summary.sarlm print.summary.spautolm print.summary.stsls residuals.gmsar residuals.lagmess residuals.sarlm residuals.spautolm residuals.stsls sacsarlm SE_classic_setup SE_interp_setup SE_whichMin_setup similar.listw spam_setup spam_update_setup SpatialFiltering spautolm spBreg_err spBreg_lag spBreg_sac spdep-defunct stsls subgraph_eigenw summary.gmsar summary.lagImpact summary.lagmess summary.sarlm summary.spautolm summary.stsls trW vcov.sarlm Wald1.sarlm
Provides constants for spatial weights matricesspweights.constants Szero
Compute the sum of dissimilarityssw
Subset a spatial weights listsubset.listw
Subset a neighbours listsubset.nb
Print and summary function for neighbours and weights listsprint.listw print.nb print.summary.listw print.summary.nb summary.listw summary.nb
Function to construct edges based on a tolerance angle and a maximum distancetolerance.nb
Neighbours list from tri objecttri2nb
Write a neighbours list as a GAL lattice filewrite.nb.gal