Skip to content

Commit

Permalink
address edzer/sdsr#121
Browse files Browse the repository at this point in the history
  • Loading branch information
rsbivand committed Feb 8, 2024
1 parent 9330dc9 commit 208f1b3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
9 changes: 7 additions & 2 deletions R/lm.RStests.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
12 changes: 12 additions & 0 deletions inst/tinytest/test_lmRStests_test_names.R
Original file line number Diff line number Diff line change
@@ -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)))
}
}

0 comments on commit 208f1b3

Please sign in to comment.