@@ -193,7 +193,11 @@ predict.Sarlm <- function(object, newdata=NULL, listw=NULL, pred.type="TS", all.
193
193
W <- as(listw , " CsparseMatrix" )
194
194
W <- W [region.id , region.id ]
195
195
style <- listw $ style
196
- listw <- mat2listw(W , row.names = region.id , style = style , zero.policy = zero.policy ) # re-normalize to keep the style
196
+ if (packageVersion(" spdep" ) > = " 1.3.1" ) {
197
+ listw <- mat2listw(W , row.names = region.id , style = style , zero.policy = zero.policy ) # re-normalize to keep the style
198
+ } else {
199
+ listw <- mat2listw(W , row.names = region.id , style = style ) # re-normalize to keep the style
200
+ }
197
201
rm(W ) # avoid the use of a wrong W
198
202
}
199
203
}
@@ -247,7 +251,11 @@ predict.Sarlm <- function(object, newdata=NULL, listw=NULL, pred.type="TS", all.
247
251
W <- as(listw.mixed , " CsparseMatrix" )
248
252
W <- W [region.id.mixed , region.id.mixed ]
249
253
style <- listw.mixed $ style
250
- listw.mixed <- mat2listw(W , row.names = region.id.mixed , style = style , zero.policy = zero.policy ) # re-normalize to keep the style
254
+ if (packageVersion(" spdep" ) > = " 1.3.1" ) {
255
+ listw.mixed <- mat2listw(W , row.names = region.id.mixed , style = style , zero.policy = zero.policy ) # re-normalize to keep the style
256
+ } else {
257
+ listw.mixed <- mat2listw(W , row.names = region.id.mixed , style = style ) # re-normalize to keep the style
258
+ }
251
259
rm(W ) # avoid the use of a wrong W
252
260
}
253
261
}
@@ -540,7 +548,11 @@ predict.Sarlm <- function(object, newdata=NULL, listw=NULL, pred.type="TS", all.
540
548
for (i in 1 : nrow(newdata )) {
541
549
region.id.temp <- c(region.id.data , region.id.newdata [i ])
542
550
Wi <- W [region.id.temp , region.id.temp ]
543
- listwi <- mat2listw(Wi , row.names = region.id.temp , style = style , zero.policy = zero.policy ) # re-normalize
551
+ if (packageVersion(" spdep" ) > = " 1.3.1" ) {
552
+ listwi <- mat2listw(Wi , row.names = region.id.temp , style = style , zero.policy = zero.policy ) # re-normalize
553
+ } else {
554
+ listwi <- mat2listw(Wi , row.names = region.id.temp , style = style ) # re-normalize to keep the style
555
+ }
544
556
if (power )
545
557
Wi <- as(listwi , " CsparseMatrix" )
546
558
Xi <- rbind(Xs , Xo [i ,])
@@ -564,7 +576,11 @@ predict.Sarlm <- function(object, newdata=NULL, listw=NULL, pred.type="TS", all.
564
576
for (i in 1 : nrow(newdata )) {
565
577
region.id.temp <- c(region.id.data , region.id.newdata [i ])
566
578
Wi <- W [region.id.temp , region.id.temp ]
567
- listwi <- mat2listw(Wi , row.names = region.id.temp , style = style , zero.policy = zero.policy ) # re-normalize
579
+ if (packageVersion(" spdep" ) > = " 1.3.1" ) {
580
+ listwi <- mat2listw(Wi , row.names = region.id.temp , style = style , zero.policy = zero.policy ) # re-normalize
581
+ } else {
582
+ listwi <- mat2listw(Wi , row.names = region.id.temp , style = style ) # re-normalize to keep the style
583
+ }
568
584
Wi <- as(listwi , " CsparseMatrix" )
569
585
Xi <- rbind(Xs , Xo [i ,])
570
586
# compute TC1 for S and o units
@@ -599,7 +615,11 @@ predict.Sarlm <- function(object, newdata=NULL, listw=NULL, pred.type="TS", all.
599
615
for (i in 1 : nrow(newdata )) {
600
616
region.id.temp <- c(region.id.data , region.id.newdata [i ])
601
617
Wi <- W [region.id.temp , region.id.temp ]
602
- listwi <- mat2listw(Wi , row.names = region.id.temp , style = style , zero.policy = zero.policy ) # re-normalize
618
+ if (packageVersion(" spdep" ) > = " 1.3.1" ) {
619
+ listwi <- mat2listw(Wi , row.names = region.id.temp , style = style , zero.policy = zero.policy ) # re-normalize
620
+ } else {
621
+ listwi <- mat2listw(Wi , row.names = region.id.temp , style = style ) # re-normalize to keep the style
622
+ }
603
623
Wi <- as(listwi , " CsparseMatrix" )
604
624
Xi <- rbind(Xs , Xo [i ,])
605
625
is.data <- 1 : length(ys )
@@ -633,7 +653,11 @@ predict.Sarlm <- function(object, newdata=NULL, listw=NULL, pred.type="TS", all.
633
653
for (i in 1 : nrow(newdata )) {
634
654
region.id.temp <- c(region.id.data , region.id.newdata [i ])
635
655
Wi <- W [region.id.temp , region.id.temp ]
636
- listwi <- mat2listw(Wi , row.names = region.id.temp , style = style , zero.policy = zero.policy ) # re-normalize
656
+ if (packageVersion(" spdep" ) > = " 1.3.1" ) {
657
+ listwi <- mat2listw(Wi , row.names = region.id.temp , style = style , zero.policy = zero.policy ) # re-normalize
658
+ } else {
659
+ listwi <- mat2listw(Wi , row.names = region.id.temp , style = style ) # re-normalize to keep the style
660
+ }
637
661
Wi <- as(listwi , " CsparseMatrix" )
638
662
Xi <- rbind(Xs , Xo [i ,])
639
663
# compute TC1 for S and o units
0 commit comments