Home > front end >  Can't find function "SpatialFiltering"
Can't find function "SpatialFiltering"

Time:07-06

I'd like to do some filtering to estimate lags for spatial data analysis, but I can't find a filtering function (SpatialFiltering).

I'd appreciate it if you could provide me with a solution to this problem.

The original data for analysis is stored in the following link.

https://drive.google.com/file/d/15BuwuajViAg3409xcEUMaBNsuF4RJ4Sj/view?usp=sharing

library(spdep)
library(spatstat)
library(spgwr)
library(nlme)
library(lme4)
library(ggplot2)
needs::prioritize(magrittr)

kanto <- sf::st_read('/cloud/project/asakura_sp_data/kanto_area.shp')
lph <- readr::read_csv("/cloud/project/asakura_sp_data/lph.csv")
kanto_lph <- dplyr::inner_join(kanto, lph, by=c("JCODE"="JCODE"))
kanto$lm.resid <- resid(lph.lm)
kanto.tri.nb <- sf::st_coordinates(sf::st_centroid(kanto)) %>%
  spdep::tri2nb()


lph.glm <- glm(LPH~POPD EMP3D offset(log(S)), data=lph)
lph.gam1 <- mgcv::gam(LPH~POPD EMP3D s(Easting, Northing), data=lph)
lph.gam2 <- mgcv::gam(LPH~POPD EMP3D offset(log(S)) s(Easting, Northing), data=lph)


lph.SF <- SpatialFiltering(LPH~POPD EMP3D, data=lph, nb=kanto.tri.nb, style="W")
Error in SpatialFiltering(LPH ~ POPD   EMP3D, data = lph, nb = kanto.tri.nb,  : 
  could not find function "SpatialFiltering"

MacBook Pro 2018,macOS Monterey,Rstudio Cloud

CodePudding user response:

The SpatialFiltering() function is no longer present in the spdep package but has been moved to the spatialreg package : https://github.com/r-spatial/spdep/blob/43e46ca1928338ce349818516129c7c3aa62d061/man/spdep-defunct.Rd.

Installing it will solve your issue :

install.packages("spatialreg")
library(spatialreg)
  • Related