@@ -84,6 +84,7 @@ spBreg_lag <- function(formula, data = list(), listw, na.action, Durbin, type,
84
84
# WX <- create_WX(x, listw, zero.policy=zero.policy, prefix="lag")
85
85
# FIXME
86
86
if (is.formula(Durbin ) || isTRUE(Durbin )) {
87
+ if (Sys.getenv(" SPATIALREG_CREATE_DURBIN" ) == " " ) {
87
88
prefix <- " lag"
88
89
if (isTRUE(Durbin )) {
89
90
if (have_factor_preds ) warn_factor_preds(have_factor_preds )
@@ -121,7 +122,7 @@ spBreg_lag <- function(formula, data = list(), listw, na.action, Durbin, type,
121
122
}
122
123
wxn <- substring(colnames(WX ), nchar(prefix )+ 2 ,
123
124
nchar(colnames(WX )))
124
- zero_fill <- NULL
125
+ zero_fill <- integer( 0L )
125
126
if (length((which(! (xn %in% wxn )))) > 0L )
126
127
zero_fill <- length(xn ) + (which(! (xn %in% wxn )))
127
128
}
@@ -135,6 +136,20 @@ spBreg_lag <- function(formula, data = list(), listw, na.action, Durbin, type,
135
136
x <- cbind(x , WX )
136
137
m <- NCOL(x )
137
138
rm(WX )
139
+ } else { # SPATIALREG_CREATE_DURBIN
140
+ res <- create_Durbin(Durbin = Durbin ,
141
+ have_factor_preds = have_factor_preds , x = x , listw = listw ,
142
+ zero.policy = zero.policy , data = data , na.act = na.act )
143
+ x <- res $ x
144
+ dvars <- res $ dvars
145
+ inds <- attr(dvars , " inds" )
146
+ xn <- attr(dvars , " xn" )
147
+ wxn <- attr(dvars , " wxn" )
148
+ zero_fill <- attr(dvars , " zero_fill" )
149
+ formula_durbin_factors <- attr(dvars , " formula_durbin_factors" )
150
+ attr(dvars , " xn" ) <- NULL
151
+ attr(dvars , " wxn" ) <- NULL
152
+ }
138
153
}
139
154
# x <- cbind(x, WX)
140
155
# rm(WX)
@@ -408,7 +423,7 @@ impacts.MCMC_sar_G <- function(obj, ..., tr=NULL, listw=NULL, evalues=NULL,
408
423
beta <- means [1 : (length(means )- 2 )]
409
424
icept <- grep(" (Intercept)" , names(beta ))
410
425
iicept <- length(icept ) > 0L
411
- zero_fill <- NULL
426
+ zero_fill <- integer( 0L )
412
427
dvars <- NULL
413
428
samples <- as.matrix(obj )
414
429
interval <- attr(obj , " control" )$ interval
@@ -569,6 +584,7 @@ spBreg_err <- function(formula, data = list(), listw, na.action, Durbin, etype,
569
584
dvars <- c(NCOL(x ), 0L )
570
585
571
586
if (is.formula(Durbin ) || isTRUE(Durbin )) {
587
+ if (Sys.getenv(" SPATIALREG_CREATE_DURBIN" ) == " " ) {
572
588
prefix <- " lag"
573
589
if (isTRUE(Durbin )) {
574
590
if (have_factor_preds ) warn_factor_preds(have_factor_preds )
@@ -606,7 +622,7 @@ spBreg_err <- function(formula, data = list(), listw, na.action, Durbin, etype,
606
622
}
607
623
wxn <- substring(colnames(WX ), nchar(prefix )+ 2 ,
608
624
nchar(colnames(WX )))
609
- zero_fill <- NULL
625
+ zero_fill <- integer( 0L )
610
626
if (length((which(! (xn %in% wxn )))) > 0L )
611
627
zero_fill <- length(xn ) + (which(! (xn %in% wxn )))
612
628
}
@@ -621,6 +637,22 @@ spBreg_err <- function(formula, data = list(), listw, na.action, Durbin, etype,
621
637
xcolnames <- colnames(x )
622
638
m <- NCOL(x )
623
639
rm(WX )
640
+ } else { # SPATIALREG_CREATE_DURBIN
641
+ res <- create_Durbin(Durbin = Durbin ,
642
+ have_factor_preds = have_factor_preds , x = x , listw = listw ,
643
+ zero.policy = zero.policy , data = data , na.act = na.act )
644
+ x <- res $ x
645
+ xcolnames <- colnames(x )
646
+ m <- NCOL(x )
647
+ dvars <- res $ dvars
648
+ inds <- attr(dvars , " inds" )
649
+ xn <- attr(dvars , " xn" )
650
+ wxn <- attr(dvars , " wxn" )
651
+ zero_fill <- attr(dvars , " zero_fill" )
652
+ formula_durbin_factors <- attr(dvars , " formula_durbin_factors" )
653
+ attr(dvars , " xn" ) <- NULL
654
+ attr(dvars , " wxn" ) <- NULL
655
+ }
624
656
}
625
657
# x <- cbind(x, WX)
626
658
# rm(WX)
@@ -1070,6 +1102,7 @@ spBreg_sac <- function(formula, data = list(), listw, listw2=NULL, na.action,
1070
1102
# WX <- create_WX(x, listw, zero.policy=zero.policy, prefix="lag")
1071
1103
# FIXME
1072
1104
if (is.formula(Durbin ) || isTRUE(Durbin )) {
1105
+ if (Sys.getenv(" SPATIALREG_CREATE_DURBIN" ) == " " ) {
1073
1106
prefix <- " lag"
1074
1107
if (isTRUE(Durbin )) {
1075
1108
if (have_factor_preds ) warn_factor_preds(have_factor_preds )
@@ -1107,7 +1140,7 @@ spBreg_sac <- function(formula, data = list(), listw, listw2=NULL, na.action,
1107
1140
}
1108
1141
wxn <- substring(colnames(WX ), nchar(prefix )+ 2 ,
1109
1142
nchar(colnames(WX )))
1110
- zero_fill <- NULL
1143
+ zero_fill <- integer( 0L )
1111
1144
if (length((which(! (xn %in% wxn )))) > 0L )
1112
1145
zero_fill <- length(xn ) + (which(! (xn %in% wxn )))
1113
1146
}
@@ -1121,6 +1154,20 @@ spBreg_sac <- function(formula, data = list(), listw, listw2=NULL, na.action,
1121
1154
x <- cbind(x , WX )
1122
1155
m <- NCOL(x )
1123
1156
rm(WX )
1157
+ } else { # SPATIALREG_CREATE_DURBIN
1158
+ res <- create_Durbin(Durbin = Durbin ,
1159
+ have_factor_preds = have_factor_preds , x = x , listw = listw ,
1160
+ zero.policy = zero.policy , data = data , na.act = na.act )
1161
+ x <- res $ x
1162
+ dvars <- res $ dvars
1163
+ inds <- attr(dvars , " inds" )
1164
+ xn <- attr(dvars , " xn" )
1165
+ wxn <- attr(dvars , " wxn" )
1166
+ zero_fill <- attr(dvars , " zero_fill" )
1167
+ formula_durbin_factors <- attr(dvars , " formula_durbin_factors" )
1168
+ attr(dvars , " xn" ) <- NULL
1169
+ attr(dvars , " wxn" ) <- NULL
1170
+ }
1124
1171
}
1125
1172
if (NROW(x ) != length(listw2 $ neighbours ))
1126
1173
stop(" Input data and neighbourhood list2 have different dimensions" )
0 commit comments