adeverse / adespatial

Multivariate Multiscale Spatial Analysis
http://adeverse.github.io/adespatial/
32 stars 7 forks source link

`listw.select()` fails with data frame assignment #29

Open JosiahParry opened 2 weeks ago

JosiahParry commented 2 weeks ago

Please see the below reprex:

library(spdep)
library(sfdep)
library(adespatial)

geo <- guerry$geometry

nb <- st_knn(geo, 10)
#> ! Polygon provided. Using point on surface.

wt <- st_kernel_weights(nb, geo, "gaussian", adaptive = TRUE)
#> ! Polygon provided. Using point on surface.

knn_lw <- nb2listw(nb, wt, "B")
contiguity_lw <- nb2listw(st_contiguity(geo))
del_lw <- nb2listw(st_nb_delaunay(geo), style = "B")
#> ! Polygon provided. Using point on surface.

x <- guerry$literacy

select_res <- listw.select(x, list(knn_lw, contiguity_lw, del_lw))
#> Procedure stopped (alpha criteria): pvalue for variable 10 is 0.054000 (> 0.050000)
#> Procedure stopped (adjR2thresh criteria) adjR2cum = 0.792070 with 10 variables (> 0.780129)
#> Procedure stopped (adjR2thresh criteria) adjR2cum = 0.706226 with 5 variables (> 0.703867)
#> Error in `[<-.data.frame`(`*tmp*`, , 1, value = c(0.763253300428723, 0.780129191853915, : replacement has 3 rows, data has 0
JosiahParry commented 2 weeks ago

Note that this fails for every method, global, MIR, and FWD as well as every listw I created.

JosiahParry commented 2 weeks ago

This appears to be because the candidate list must be named