@@ -109,6 +109,7 @@ errorsarlm <- function(formula, data = list(), listw, na.action, weights=NULL,
109
109
dvars <- c(NCOL(x ), 0L )
110
110
111
111
if (is.formula(Durbin ) || isTRUE(Durbin )) {
112
+ if (Sys.getenv(" SPATIALREG_CREATE_DURBIN" ) == " " ) {
112
113
prefix <- " lag"
113
114
if (isTRUE(Durbin )) {
114
115
WX <- create_WX(x , listw , zero.policy = zero.policy ,
@@ -145,7 +146,7 @@ errorsarlm <- function(formula, data = list(), listw, na.action, weights=NULL,
145
146
}
146
147
wxn <- substring(colnames(WX ), nchar(prefix )+ 2 ,
147
148
nchar(colnames(WX )))
148
- zero_fill <- NULL
149
+ zero_fill <- integer( 0L )
149
150
if (length((which(! (xn %in% wxn )))) > 0L )
150
151
zero_fill <- length(xn ) + (which(! (xn %in% wxn )))
151
152
}
@@ -159,6 +160,21 @@ errorsarlm <- function(formula, data = list(), listw, na.action, weights=NULL,
159
160
x <- cbind(x , WX )
160
161
m <- NCOL(x )
161
162
rm(WX )
163
+ } else { # SPATIALREG_CREATE_DURBIN
164
+ res <- create_Durbin(Durbin = Durbin ,
165
+ have_factor_preds = have_factor_preds , x = x , listw = listw ,
166
+ zero.policy = zero.policy , data = data , na.act = na.act )
167
+ x <- res $ x
168
+ dvars <- res $ dvars
169
+ inds <- attr(dvars , " inds" )
170
+ xn <- attr(dvars , " xn" )
171
+ wxn <- attr(dvars , " wxn" )
172
+ zero_fill <- attr(dvars , " zero_fill" )
173
+ formula_durbin_factors <- attr(dvars , " formula_durbin_factors" )
174
+ attr(dvars , " xn" ) <- NULL
175
+ attr(dvars , " wxn" ) <- NULL
176
+ }
177
+
162
178
}
163
179
# added aliased after trying boston with TOWN dummy
164
180
lm.base <- lm(y ~ x - 1 , weights = weights )
@@ -640,6 +656,7 @@ lagsarlm <- function(formula, data = list(), listw,
640
656
dvars <- c(NCOL(x ), 0L )
641
657
# FIXME
642
658
if (is.formula(Durbin ) || isTRUE(Durbin )) {
659
+ if (Sys.getenv(" SPATIALREG_CREATE_DURBIN" ) == " " ) {
643
660
prefix <- " lag"
644
661
if (isTRUE(Durbin )) {
645
662
WX <- create_WX(x , listw , zero.policy = zero.policy ,
@@ -674,7 +691,7 @@ lagsarlm <- function(formula, data = list(), listw,
674
691
}
675
692
wxn <- substring(colnames(WX ), nchar(prefix )+ 2 ,
676
693
nchar(colnames(WX )))
677
- zero_fill <- NULL
694
+ zero_fill <- integer( 0L )
678
695
if (length((which(! (xn %in% wxn )))) > 0L )
679
696
zero_fill <- length(xn ) + (which(! (xn %in% wxn )))
680
697
}
@@ -688,6 +705,20 @@ lagsarlm <- function(formula, data = list(), listw,
688
705
x <- cbind(x , WX )
689
706
m <- NCOL(x )
690
707
rm(WX )
708
+ } else { # SPATIALREG_CREATE_DURBIN
709
+ res <- create_Durbin(Durbin = Durbin ,
710
+ have_factor_preds = have_factor_preds , x = x , listw = listw ,
711
+ zero.policy = zero.policy , data = data , na.act = na.act )
712
+ x <- res $ x
713
+ dvars <- res $ dvars
714
+ inds <- attr(dvars , " inds" )
715
+ xn <- attr(dvars , " xn" )
716
+ wxn <- attr(dvars , " wxn" )
717
+ zero_fill <- attr(dvars , " zero_fill" )
718
+ formula_durbin_factors <- attr(dvars , " formula_durbin_factors" )
719
+ attr(dvars , " xn" ) <- NULL
720
+ attr(dvars , " wxn" ) <- NULL
721
+ }
691
722
}
692
723
# added aliased after trying boston with TOWN dummy
693
724
lm.base <- lm(y ~ x - 1 )
@@ -1010,6 +1041,7 @@ sacsarlm <- function(formula, data = list(), listw, listw2=NULL, na.action,
1010
1041
dvars <- c(m , 0L )
1011
1042
# if (type != "sac") {
1012
1043
if (is.formula(Durbin ) || isTRUE(Durbin )) {
1044
+ if (Sys.getenv(" SPATIALREG_CREATE_DURBIN" ) == " " ) {
1013
1045
prefix <- " lag"
1014
1046
if (isTRUE(Durbin )) {
1015
1047
if (have_factor_preds ) warn_factor_preds(have_factor_preds )
@@ -1047,7 +1079,7 @@ sacsarlm <- function(formula, data = list(), listw, listw2=NULL, na.action,
1047
1079
}
1048
1080
wxn <- substring(colnames(WX ), nchar(prefix )+ 2 ,
1049
1081
nchar(colnames(WX )))
1050
- zero_fill <- NULL
1082
+ zero_fill <- integer( 0L )
1051
1083
if (length((which(! (xn %in% wxn )))) > 0L )
1052
1084
zero_fill <- length(xn ) + (which(! (xn %in% wxn )))
1053
1085
}
@@ -1061,6 +1093,20 @@ sacsarlm <- function(formula, data = list(), listw, listw2=NULL, na.action,
1061
1093
x <- cbind(x , WX )
1062
1094
m <- NCOL(x )
1063
1095
rm(WX )
1096
+ } else { # SPATIALREG_CREATE_DURBIN
1097
+ res <- create_Durbin(Durbin = Durbin ,
1098
+ have_factor_preds = have_factor_preds , x = x , listw = listw ,
1099
+ zero.policy = zero.policy , data = data , na.act = na.act )
1100
+ x <- res $ x
1101
+ dvars <- res $ dvars
1102
+ inds <- attr(dvars , " inds" )
1103
+ xn <- attr(dvars , " xn" )
1104
+ wxn <- attr(dvars , " wxn" )
1105
+ zero_fill <- attr(dvars , " zero_fill" )
1106
+ formula_durbin_factors <- attr(dvars , " formula_durbin_factors" )
1107
+ attr(dvars , " xn" ) <- NULL
1108
+ attr(dvars , " wxn" ) <- NULL
1109
+ }
1064
1110
}
1065
1111
if (NROW(x ) != length(listw2 $ neighbours ))
1066
1112
stop(" Input data and neighbourhood list2 have different dimensions" )
0 commit comments