Skip to content

Commit 9b71ac6

Browse files
committed
tidy
2 parents 5f85261 + ddd1e23 commit 9b71ac6

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

R/SLX_WX.R

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ impacts.SlX <- function(obj, ...) {
272272
stopifnot(!is.null(attr(obj, "mixedImps")))
273273
n <- nrow(obj$model)
274274
k <- obj$qr$rank
275-
impactsWX(attr(obj, "mixedImps"), n, k, type="SlX", method="glht")
275+
impactsWX(attr(obj, "mixedImps"), n, k, type="SlX", method="glht",
276+
have_factor_preds=attr(obj, "have_factor_preds"))
276277
}
277278

278279
impactsWX <- function(obj, n, k, type="SlX", method="glht", have_factor_preds=FALSE) {
@@ -302,6 +303,30 @@ update_bnames <- function(bnames, have_factor_preds=FALSE) {
302303
for (pred in seq(along=factnames)) {
303304
npred <- grep(paste0("^", factnames[pred], ".*"), bnames)
304305
b_suffix[npred] <- "(F)"
306+
#=======
307+
# xlevels <- attr(have_factor_preds, "xlevels")
308+
# contrasts <- attr(have_factor_preds, "pred_contrasts")
309+
# for (pred in seq(along=factnames)) {
310+
# npred <- grep(factnames[pred], bnames)
311+
# xlpred <- xlevels[[pred]]
312+
# cpred <- contrasts[[pred]]
313+
# if (length(npred) >= length(xlpred)) {
314+
# b_suffix[npred] <- ""
315+
# } else {
316+
# if (cpred == "contr.treatment") {
317+
# b_suffix[npred] <- xlpred[-1]
318+
# } else if (cpred == "code_control") {
319+
# b_suffix[npred] <- paste(xlpred[-1], "vs.", xlpred[1])
320+
# } else if (cpred == "code_diff") {
321+
# b_suffix[npred] <- paste(xlpred[-1], "vs.",
322+
# xlpred[-length(xlpred)])
323+
# } else if (cpred == "contr.poly") {
324+
# b_suffix[npred] <- "poly"
325+
# } else {
326+
# b_suffix[npred] <- ""
327+
# }
328+
# }
329+
#>>>>>>> ddd1e233b0387bd18bd409837b00671295e6001d
305330
}
306331
}
307332
bnames <- paste(bnames, b_suffix)

inst/tinytest/test_Durbin_factor.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@ data(oldcol, package="spdep")
33
lw <- spdep::nb2listw(COL.nb)
44
COL.OLD$fEW <- factor(COL.OLD$EW)
55
COL.OLD$fDISCBD <- ordered(cut(COL.OLD$DISCBD, c(0, 1.5, 3, 4.5, 6)))
6-
f <- formula(CRIME ~ INC + HOVAL + fDISCBD*fEW)
6+
f <- formula(CRIME ~ INC + HOVAL + fDISCBD + fEW)
77
expect_warning(COL.SLX0 <- lmSLX(f, data=COL.OLD, lw, Durbin=TRUE))
8-
expect_warning(COL.SLX1 <- lmSLX(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD*fEW))
8+
expect_warning(COL.SLX1 <- lmSLX(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD + fEW))
99
expect_warning(COL.SLX2 <- lmSLX(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fEW))
1010
expect_silent(COL.SLX3 <- lmSLX(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL))
1111
expect_warning(COL.err0 <- errorsarlm(f, data=COL.OLD, lw, Durbin=TRUE))
12-
expect_warning(COL.err1 <- errorsarlm(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD*fEW))
12+
expect_warning(COL.err1 <- errorsarlm(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD + fEW))
1313
expect_warning(COL.err2 <- errorsarlm(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD))
1414
expect_silent(COL.err3 <- errorsarlm(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL))
1515
expect_warning(COL.lag0 <- lagsarlm(f, data=COL.OLD, lw, Durbin=TRUE))
16-
expect_warning(COL.lag1 <- lagsarlm(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD*fEW))
16+
expect_warning(COL.lag1 <- lagsarlm(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD + fEW))
1717
expect_warning(COL.lag2 <- lagsarlm(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD))
1818
expect_silent(COL.lag3 <- lagsarlm(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL))
1919
expect_warning(COL.sac0 <- sacsarlm(f, data=COL.OLD, lw, Durbin=TRUE))
20-
expect_warning(COL.sac1 <- sacsarlm(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD*fEW))
20+
expect_warning(COL.sac1 <- sacsarlm(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD + fEW))
2121
expect_warning(COL.sac2 <- sacsarlm(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD))
2222
expect_silent(COL.sac3 <- sacsarlm(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL))
2323
expect_warning(COL.lag0 <- spBreg_lag(f, data=COL.OLD, lw, Durbin=TRUE))
24-
expect_warning(COL.lag1 <- spBreg_lag(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD*fEW))
24+
expect_warning(COL.lag1 <- spBreg_lag(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD + fEW))
2525
expect_warning(COL.lag2 <- spBreg_lag(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD))
2626
expect_silent(COL.lag3 <- spBreg_lag(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL))
2727
expect_warning(COL.err0 <- spBreg_err(f, data=COL.OLD, lw, Durbin=TRUE))
28-
expect_warning(COL.err1 <- spBreg_err(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD*fEW))
28+
expect_warning(COL.err1 <- spBreg_err(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD + fEW))
2929
expect_warning(COL.err2 <- spBreg_err(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD))
3030
expect_silent(COL.err3 <- spBreg_err(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL))
3131
expect_warning(COL.sac0 <- spBreg_sac(f, data=COL.OLD, lw, Durbin=TRUE))
32-
expect_warning(COL.sac1 <- spBreg_sac(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD*fEW))
32+
expect_warning(COL.sac1 <- spBreg_sac(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD + fEW))
3333
expect_warning(COL.sac2 <- spBreg_sac(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL + fDISCBD))
3434
expect_silent(COL.sac3 <- spBreg_sac(f, data=COL.OLD, lw, Durbin=~ INC + HOVAL))
3535

0 commit comments

Comments
 (0)