diff --git a/DESCRIPTION b/DESCRIPTION index 8c0ee479..167c0276 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: spdep -Version: 1.3-3 -Date: 2024-02-06 +Version: 1.3-4 +Date: 2024-02-07 Title: Spatial Dependence: Weighting Schemes, Statistics Encoding: UTF-8 Authors@R: c(person("Roger", "Bivand", role = c("cre", "aut"), diff --git a/NEWS.md b/NEWS.md index 6e446acf..8efd5a52 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,8 @@ -# Version 1.3-3 (development) +# Version 1.3-4 (development) + +* fix https://github.com/edzer/sdsr/issues/121, wrong assignment of old test names in `lmRStests` + +# Version 1.3-3 (2024-02-07) * change `lm.LMtests` to `lm.RStests` and re-name Lagrange multiplier to Rao's score; add `GNM_` prefix to test names if the input object inherits from `SlX` created by `spatialreg::lmSLX` (Koley, forthcoming) diff --git a/R/lm.RStests.R b/R/lm.RStests.R index 1e11f09f..6f77bc4e 100644 --- a/R/lm.RStests.R +++ b/R/lm.RStests.R @@ -41,8 +41,13 @@ lm.RStests <- function(model, listw, zero.policy=attr(listw, "zero.policy"), tes if (test[1] == "all") { test <- all.tests } else { - o <- match(test, old.tests) - if (any(!is.na(o))) test[o[!is.na(o)]] <- all.tests[o[!is.na(o)]] + o <- match(old.tests, test) + if (any(!is.na(o))) { + for (i in seq(along=test)) { + m <- match(test[i], old.tests) + test[i] <- all.tests[m] + } + } } if (!all(test %in% all.tests)) stop("Invalid test selected - must be either \"all\" or a vector of tests") diff --git a/inst/tinytest/test_lmRStests_test_names.R b/inst/tinytest/test_lmRStests_test_names.R new file mode 100644 index 00000000..fef20091 --- /dev/null +++ b/inst/tinytest/test_lmRStests_test_names.R @@ -0,0 +1,12 @@ +library(spdep) +data(oldcol) +oldcrime.lm <- lm(CRIME ~ HOVAL + INC, data = COL.OLD) +lw <- nb2listw(COL.nb) +old.tests <- c("LMerr", "LMlag", "RLMerr", "RLMlag", "SARMA") +set.seed(1) +for (i in 1:4) { + for (j in 1:5) { + expect_silent(res <- lm.RStests(oldcrime.lm, listw=lw, test=sample(old.tests, size=i))) + expect_message(res <- lm.LMtests(oldcrime.lm, listw=lw, test=sample(old.tests, size=i))) + } +}