diff --git a/docs/articles/nb_igraph.html b/docs/articles/nb_igraph.html index 7ab39dd..a200616 100644 --- a/docs/articles/nb_igraph.html +++ b/docs/articles/nb_igraph.html @@ -162,7 +162,7 @@

## Loading required package: spData
## Loading required package: Matrix
## Loading required package: sf
-
## Linking to GEOS 3.12.1, GDAL 3.9.0beta1, PROJ 9.4.0; sf_use_s2() is TRUE
+
## Linking to GEOS 3.12.1, GDAL 3.9.0, PROJ 9.4.0; sf_use_s2() is TRUE

Getting some data @@ -181,7 +181,7 @@

Getting some datasf_extSoftVersion() }

##           GEOS           GDAL         proj.4 GDAL_with_GEOS     USE_PROJ_H 
-##       "3.12.1"   "3.9.0beta1"        "9.4.0"         "true"         "true" 
+##       "3.12.1"        "3.9.0"        "9.4.0"         "true"         "true" 
 ##           PROJ 
 ##        "9.4.0"
@@ -312,13 +312,16 @@ 

Symmetric sparse matrices
 nb_B1 <- spdep::mat2listw(as(as(B, "TsparseMatrix"), "CsparseMatrix"),
-    style="B", zero.policy=TRUE)
-nb_B1$style
-
## [1] "B"
+ style="B", zero.policy=TRUE)

+
## Warning in sn2listw(df, style = style, zero.policy = zero.policy, from_mat2listw = TRUE): no-neighbour observations found, set zero.policy to TRUE;
+## this warning will soon become an error
+nb_B1$style
+
## [1] "B"
+
 all.equal(nb_B1$neighbours, col2, check.attributes=FALSE)
## [1] TRUE
-
+
 all.equal(attr(nb_B1$neighbours, "region.id"), attr(nb_B$neighbours, "region.id"))
## [1] TRUE
@@ -331,7 +334,7 @@

Log deter the eigenvalue approach with for example spatialreg::eigenw is limited by the need to operate on dense matrices in memory to solve the eigenproblem:

-
+
 rho <- 0.1
 do_spatialreg <- FALSE
 if (requireNamespace("spatialreg", quietly=TRUE)) do_spatialreg <- TRUE
@@ -346,14 +349,14 @@ 

Log deter "dsTMatrix", from a "ddiMatrix". The value of the log determinant follows, calling a sparse Cholesky decomposition internally for suitable input matrices.

-
+
 n <- nrow(B)
 I <- Diagonal(n)
 class(I - rho * B)
## [1] "dgCMatrix"
 ## attr(,"package")
 ## [1] "Matrix"
-
+
 c(determinant(I - rho * B, logarithm=TRUE)$modulus)
## [1] -1.44787

The computation of a sparse Cholesky decomposition for each value of @@ -361,7 +364,7 @@

Log deter avoided by updating a pre-computed object; this approach provides fast and accurate log determinants for larger (but not very large) data sets:

-
+
 nW <- -B
 nChol <- Cholesky(nW, Imult=8)
 n * log(rho) + (2 * c(determinant(update(nChol, nW, 1/rho), sqrt=TRUE)$modulus))
@@ -373,7 +376,7 @@

Asymmetric sparse matricesThe use of row-standardisation leads to asymmetry even if the underlying neighbours are symmetric, unless all entities have matching numbers of neighbours (for example a regular grid on a torus):

-
+
 nb_W <- spdep::nb2listw(col2, style="W", zero.policy=TRUE)
 W <- as(nb_W, "CsparseMatrix")
 str(W)
@@ -386,7 +389,7 @@

Asymmetric sparse matrices## .. ..$ : chr [1:49] "1" "2" "3" "4" ... ## ..@ x : num [1:230] 0.333 0.25 0.5 0.25 0.25 ... ## ..@ factors : list()

-
+
 all(W == t(W))
## [1] FALSE

The lag method for listw objects is often @@ -395,17 +398,17 @@

Asymmetric sparse matriceszero.policy to TRUE, the spatial lag of entity 21, which has no neighbours, is zero by construction:

-
+
 set.seed(1)
 x <- runif(n)
 r1 <- as.numeric(W %*% x)
 r2 <- lag(nb_W, x, zero.policy=TRUE)
 all.equal(r1, r2, check.attributes=FALSE)
## [1] TRUE
-
+
 plot(x, r1, ylim=c(0,1))

-
+
 c(x[21], r1[21])
## [1] 0.9347052 0.0000000
@@ -419,20 +422,20 @@

Log dete result may be a complex vector (here it is not, as discussed below). The appropriate determinant method for "dgCMatrix" objects uses an LU decomposition internally:

-
+
 rho <- 0.5
 sum(log(1 - rho * eigenw(nb_W)))
## [1] -1.594376
-
+
 class(I - rho * W)
## [1] "dgCMatrix"
 ## attr(,"package")
 ## [1] "Matrix"
-
+
 c(determinant(I - rho * W, logarithm=TRUE)$modulus)
## [1] -1.594376

We can show the internal workings of the method as:

-
+
 LU <- lu(I - rho * W)
 sum(log(abs(diag(slot(LU, "U")))))
## [1] -1.594376
@@ -446,7 +449,7 @@

Log determinants: symmetric by less costly numerical methods. The "W" style used the cardinalities of neighbour sets (row sums) to introduce row standardisation, and they are stored as an attribute:

-
+
 d <- attr(nb_W$weights, "comp")$d
 all.equal(d, spdep::card(col2))
## [1] TRUE
@@ -454,24 +457,24 @@

Log determinants: symmetric by (which must be symmetric), we can pre- and post-multiply by the square roots of the inverted neighbour counts, yielding a symmetric matrix with the appropriate properties:

-
+
 dW <- Diagonal(n, d) %*% W
 all(dW == t(dW))
## [1] TRUE
-
+
 isd <- Diagonal(n, 1/sqrt(d))
 isd[21,21]
## [1] Inf
-
+
 Ws <- as(isd %*% dW %*% isd, "symmetricMatrix")
 rowSums(Ws)[21]
## [1] 0
-
+
 class(Ws)
## [1] "dsCMatrix"
 ## attr(,"package")
 ## [1] "Matrix"
-
+
 c(determinant(I - rho * Ws, logarithm=TRUE)$modulus)
## [1] -1.594376

As can be seen, the division by the square root of zero for entity 21 @@ -492,19 +495,19 @@

Using eigsn is somewhat larger, use may be made of the eigs function in RSpectra:

-
+
 1/range(spatialreg::eigenw(nb_B))
## [1] -0.3212551  0.1638329
-
+
 if (!require("RSpectra", quietly=TRUE)) dothis <- FALSE
-
+
 1/c(eigs(B, k=1, which="SR")$values, eigs(B, k=1, which="LR")$values)
## [1] -0.3212551  0.1638329

In this case, the results are trivial with small k.

-
+
 1/range(eigenw(nb_W))
## [1] -1.544645  1.000000
-
+
 1/Re(c(eigs(W, k=1, which="SR")$values, eigs(W, k=1, which="LR")$values))
## [1] -1.544645  1.000000

Using row-standardisation has the nice feature of setting the upper @@ -520,15 +523,15 @@

Converting from sym

First we’ll see how to get from sparse matrices to graphs. The mode of a symmetric matrix is "undirected" by definition:

-
+
 class(B)
## [1] "dgCMatrix"
 ## attr(,"package")
 ## [1] "Matrix"
-
+
 
## 10824 bytes
-
+
 if (!require("igraph", quietly=FALSE)) dothis <- FALSE
## Loading required package: igraph
## 
@@ -539,11 +542,11 @@ 

Converting from sym
## The following object is masked from 'package:base':
 ## 
 ##     union
-
+
 g1 <- graph_from_adjacency_matrix(B, mode="undirected")
 class(g1)
## [1] "igraph"
-
+
 
## 6544 bytes
@@ -554,7 +557,7 @@

Converting from gra get.adjacency chooses a particular class of sparse matrix to be returned, so that the conversion process typically leads many matrices to fewer graph types, and back to fewer matrix types:

-
+
 # Matrix 1.4-2 vulnerability work-around
 ow <- options("warn")$warn
 options("warn"=2L)
@@ -563,13 +566,13 @@ 

Converting from gra
## [1] "dgCMatrix"
 ## attr(,"package")
 ## [1] "Matrix"
-
+
 if (!inherits(B1, "try-error")) print(object.size(B1))
## 10824 bytes
-
+
 if (!inherits(B1, "try-error")) print(all.equal(B, as(B1, "CsparseMatrix")))
## [1] TRUE
-
+
 options("warn"=ow)
@@ -580,7 +583,7 @@

Graph components in spdepn.comp.nb from the early days of the package. It is useful to know whether an nb object is divided up into separate subgraphs, and which entities are members of which such subgraph.

-
+
 res <- spdep::n.comp.nb(col2)
 table(res$comp.id)
## 
@@ -592,18 +595,18 @@ 

Graph components in igraph<

The same result can be obtained using the clusters function in igraph:

-
+
 c1 <- components(g1)
 c1$no == res$nc
## [1] TRUE
-
+
 all.equal(c1$membership, res$comp.id)
## [1] "names for target but not for current"
-
+
 all.equal(c1$csize, c(table(res$comp.id)), check.attributes=FALSE)
## [1] TRUE

The same holds for the row-standardised variant:

-
+
 W <- as(spdep::nb2listw(col2, style="W", zero.policy=TRUE), "CsparseMatrix")
 g1W <- graph_from_adjacency_matrix(W, mode="directed", weighted="W")
 c1W <- components(g1W)
@@ -622,14 +625,14 @@ 

Shortest paths in weights mat above. The diameter measure is then the diameter of the largest component subgraph. Note that this generates an n x n matrix:

-
+
 
## [1] FALSE
-
+
 dg1 <- diameter(g1)
 dg1
## [1] 7
-
+
 sp_mat <- distances(g1)
 str(sp_mat)
##  num [1:49, 1:49] 0 1 1 2 2 3 4 3 3 4 ...
@@ -645,7 +648,7 @@ 

Shortest paths in weights matr in advance (the largest lag order for which the number of links is greater than zero), we run into the problem of how to represent missing neighbour information.

-
+
 nbl10 <- spdep::nblag(col2, maxlag=10)
 vals <- sapply(nbl10, function(x) sum(spdep::card(x)))
 zero <- which(vals == 0)
@@ -657,7 +660,7 @@ 

Shortest paths in weights matr produced by shortest.paths, we need to set all these non-structural zeros to infinity (the length of the path between unconnected nodes), and re-instate structural zeros on the diagonal:

-
+
 lmat <- lapply(nbl10[1:(zero[1]-1)], spdep::nb2mat, style="B", zero.policy=TRUE)
 mat <- matrix(0, n, n)
 for (i in seq(along=lmat)) mat = mat + i*lmat[[i]]
@@ -691,23 +694,23 @@ 

Smirnov/Anselin (2009) cyclical m this for each block/subgraph by testing the condition until it meets w[j,k] > 0, at which point it breaks. Smirnov and Anselin (2009) state that rook neighbours on a regular grid meet the condition:

-
+
 nb_r <- spdep::cell2nb(7, 7, type="rook")
 nb_rW <- spdep::nb2listw(nb_r, style="W")
 spdep:::find_q1_q2(nb_rW)
## [1] 1 1

One block/graph component is found, and this one meets the cyclical matrix condition, as also shown by the domain:

-
+
 
## [1] -1  1

This does not apply to the spatial weights we have been using above, with two non-singleton components, neither meeting the cyclical matrix condition:

-
+
 spdep:::find_q1_q2(nb_W)
## [1] 2 0
-
+
 
## [1] -1.544645  1.000000

By construction, all two-node connected graph components also meet diff --git a/docs/articles/sids_models.html b/docs/articles/sids_models.html index d4b78d5..a7c7117 100644 --- a/docs/articles/sids_models.html +++ b/docs/articles/sids_models.html @@ -121,7 +121,7 @@

Getting the data into R

We will be using the spdep and spatialreg packages, here version: spdep, version -1.3-4, 2024-03-27, the sf package and the +1.3-4, 2024-05-31, the sf package and the tmap package. The data from the sources referred to above is documented in the help page for the nc.sids data set in diff --git a/docs/news/index.html b/docs/news/index.html index bb534c0..728e711 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -64,8 +64,11 @@

Changelog

- -
  • add sqrt=TRUE in calls to Matrix determinant methods in matrix_ldet

  • + +
    • protect errorsarlm against missing Durbin= if only intercept

    • +
    • fix longstanding bugs in getVmate in a non-default side logic branch

    • +
    • add return_impacts= to lmSLX to work around issues with aliased variables; impacts should be improved to handle this case when time permits

    • +
    • add sqrt=TRUE in calls to Matrix determinant methods in matrix_ldet

    • add igraph (>= 2.0.0) in DESCRIPTION for re-named igraph functions

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 4cda807..0c5a74b 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -5,5 +5,5 @@ articles: nb_igraph: nb_igraph.html sids_models: sids_models.html SpatialFiltering: SpatialFiltering.html -last_built: 2024-04-29T13:14Z +last_built: 2024-05-31T15:10Z diff --git a/docs/reference/ME.html b/docs/reference/ME.html index 48ae762..838f2c3 100644 --- a/docs/reference/ME.html +++ b/docs/reference/ME.html @@ -168,7 +168,7 @@

Examples

#> eV[,1], I: 0.08290518 ZI: NA, pr(ZI): 0.04 #> eV[,9], I: 0.06426565 ZI: NA, pr(ZI): 0.14 #> user system elapsed -#> 1.202 0.007 1.222 +#> 1.512 0.005 1.527 glmME <- glm(c(hopkins_part) ~ 1 + fitted(MEbinom1), family="binomial") #anova(glmME, test="Chisq") coef(summary(glmME)) @@ -220,7 +220,7 @@

Examples

#> eV[,6], I: 0.1178225 ZI: NA, pr(ZI): 0.08 #> eV[,4], I: 0.06242664 ZI: NA, pr(ZI): 0.27 #> user system elapsed -#> 0.589 0.003 0.606 +#> 0.636 0.000 0.639 lagcol1 #> Eigenvector ZI pr(ZI) #> 0 NA NA 0.01 diff --git a/docs/reference/ML_models.html b/docs/reference/ML_models.html index 4cca555..f161fa5 100644 --- a/docs/reference/ML_models.html +++ b/docs/reference/ML_models.html @@ -312,6 +312,9 @@

Control arguments

pre_eig

default NULL; may be used to pass a pre-computed vector of eigenvalues

+
return_impacts
+

default TRUE; may be set FALSE to avoid problems calculating impacts with aliased variables

+
OrdVsign

default 1; used to set the sign of the final component to negative if -1 (alpha times ((sigma squared) squared) in Ord (1975) equation B.1).

@@ -584,7 +587,7 @@

Examples

#> Computing eigenvalues ... #> #> user system elapsed -#> 0.143 0.000 0.145 +#> 0.214 0.000 0.216 summary(COL.lag.M) #> #> Call:lagsarlm(formula = CRIME ~ INC + HOVAL, data = COL.OLD, listw = listw, @@ -640,7 +643,7 @@

Examples

#> Computing eigenvalues ... #> #> user system elapsed -#> 0.394 0.000 0.396 +#> 0.564 0.003 0.571 summary(COL.lag.sp) #> #> Call:lagsarlm(formula = CRIME ~ INC + HOVAL, data = COL.OLD, listw = listw, @@ -1421,83 +1424,83 @@

Examples

#> 2.22497381 print(system.time(ev <- eigenw(similar.listw(listw)))) #> user system elapsed -#> 0.001 0.000 0.001 +#> 0.001 0.000 0.002 print(system.time(COL.errW.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, listw, method="eigen", control=list(pre_eig=ev)))) #> user system elapsed -#> 0.143 0.000 0.143 +#> 0.224 0.000 0.226 ocoef <- coefficients(COL.errW.eig) print(system.time(COL.errW.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, listw, method="eigen", control=list(pre_eig=ev, LAPACK=FALSE)))) #> user system elapsed -#> 0.139 0.000 0.140 +#> 0.253 0.000 0.254 print(all.equal(ocoef, coefficients(COL.errW.eig))) #> [1] TRUE print(system.time(COL.errW.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, listw, method="eigen", control=list(pre_eig=ev, compiled_sse=TRUE)))) #> user system elapsed -#> 0.151 0.000 0.153 +#> 0.231 0.000 0.233 print(all.equal(ocoef, coefficients(COL.errW.eig))) #> [1] TRUE print(system.time(COL.errW.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, listw, method="Matrix_J", control=list(super=TRUE)))) #> Warning: the default value of argument 'sqrt' of method 'determinant(<CHMfactor>, <logical>)' may change from TRUE to FALSE as soon as the next release of Matrix; set 'sqrt' when programming #> user system elapsed -#> 0.159 0.000 0.160 +#> 0.250 0.000 0.252 print(all.equal(ocoef, coefficients(COL.errW.eig))) #> [1] TRUE print(system.time(COL.errW.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, listw, method="Matrix_J", control=list(super=FALSE)))) #> user system elapsed -#> 0.158 0.000 0.160 +#> 0.266 0.000 0.269 print(all.equal(ocoef, coefficients(COL.errW.eig))) #> [1] TRUE print(system.time(COL.errW.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, listw, method="Matrix_J", control=list(super=as.logical(NA))))) #> user system elapsed -#> 0.158 0.000 0.159 +#> 0.229 0.000 0.232 print(all.equal(ocoef, coefficients(COL.errW.eig))) #> [1] TRUE print(system.time(COL.errW.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, listw, method="Matrix", control=list(super=TRUE)))) #> user system elapsed -#> 0.144 0.000 0.144 +#> 0.232 0.000 0.234 print(all.equal(ocoef, coefficients(COL.errW.eig))) #> [1] TRUE print(system.time(COL.errW.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, listw, method="Matrix", control=list(super=FALSE)))) #> user system elapsed -#> 0.144 0.000 0.144 +#> 0.213 0.000 0.214 print(all.equal(ocoef, coefficients(COL.errW.eig))) #> [1] TRUE print(system.time(COL.errW.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, listw, method="Matrix", control=list(super=as.logical(NA))))) #> user system elapsed -#> 0.143 0.000 0.145 +#> 0.298 0.000 0.300 print(all.equal(ocoef, coefficients(COL.errW.eig))) #> [1] TRUE print(system.time(COL.errW.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, listw, method="spam", control=list(spamPivot="MMD")))) #> user system elapsed -#> 0.150 0.001 0.152 +#> 0.324 0.002 0.337 print(all.equal(ocoef, coefficients(COL.errW.eig))) #> [1] TRUE print(system.time(COL.errW.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, listw, method="spam", control=list(spamPivot="RCM")))) #> user system elapsed -#> 0.152 0.000 0.152 +#> 0.254 0.000 0.256 print(all.equal(ocoef, coefficients(COL.errW.eig))) #> [1] TRUE print(system.time(COL.errW.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, listw, method="spam_update", control=list(spamPivot="MMD")))) #> user system elapsed -#> 0.149 0.000 0.149 +#> 0.287 0.000 0.300 print(all.equal(ocoef, coefficients(COL.errW.eig))) #> [1] TRUE print(system.time(COL.errW.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, listw, method="spam_update", control=list(spamPivot="RCM")))) #> user system elapsed -#> 0.168 0.000 0.169 +#> 0.227 0.000 0.229 print(all.equal(ocoef, coefficients(COL.errW.eig))) #> [1] TRUE # } diff --git a/docs/reference/SLX.html b/docs/reference/SLX.html index 67f8dce..3157ee8 100644 --- a/docs/reference/SLX.html +++ b/docs/reference/SLX.html @@ -70,7 +70,7 @@

Spatial Durbin linear (SLX, spatially lagged X) model

lmSLX(formula, data = list(), listw, na.action, weights=NULL, Durbin=TRUE,
- zero.policy=NULL)
+ zero.policy=NULL, return_impacts=TRUE)
 # S3 method for SlX
 print(x, digits = max(3L, getOption("digits") - 3L), ...)
 # S3 method for SlX
@@ -115,6 +115,9 @@ 

Arguments

zero.policy

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+
return_impacts
+

default TRUE; may be set FALSE to avoid problems calculating impacts with aliased variables

+
digits

the number of significant digits to use when printing

diff --git a/docs/reference/aple.html b/docs/reference/aple.html index 4798cea..4a0b37e 100644 --- a/docs/reference/aple.html +++ b/docs/reference/aple.html @@ -149,7 +149,17 @@

Examples

#> [1] 0.6601805 # \dontrun{ errorsarlm(yield_detrend ~ 1, wheat, spdep::nb2listw(nbr12, style="W")) -#> Error in errorsarlm(yield_detrend ~ 1, wheat, spdep::nb2listw(nbr12, style = "W")): argument "Durbin" is missing, with no default +#> +#> Call: +#> errorsarlm(formula = yield_detrend ~ 1, data = wheat, listw = spdep::nb2listw(nbr12, +#> style = "W")) +#> Type: error +#> +#> Coefficients: +#> lambda (Intercept) +#> 0.60189687 -0.00251772 +#> +#> Log likelihood: -192.9519 # }
diff --git a/docs/reference/invIrM.html b/docs/reference/invIrM.html index 38ed769..fc961af 100644 --- a/docs/reference/invIrM.html +++ b/docs/reference/invIrM.html @@ -178,16 +178,16 @@

Examples

x <- matrix(rnorm(length(nb7rt)), ncol=1) system.time(e <- invIrM(nb7rt, rho=0.9, method="chol", feasible=TRUE) %*% x) #> user system elapsed -#> 0.002 0.000 0.003 +#> 0.003 0.000 0.003 system.time(e <- invIrM(nb7rt, rho=0.9, method="chol", feasible=NULL) %*% x) #> user system elapsed -#> 0.003 0.000 0.003 +#> 0.002 0.000 0.003 system.time(e <- invIrM(nb7rt, rho=0.9, method="solve", feasible=TRUE) %*% x) #> user system elapsed #> 0.001 0.000 0.001 system.time(e <- invIrM(nb7rt, rho=0.9, method="solve", feasible=NULL) %*% x) #> user system elapsed -#> 0.001 0.000 0.002 +#> 0.002 0.000 0.001 # }
diff --git a/docs/reference/lagmess.html b/docs/reference/lagmess.html index a6e501d..103ecf3 100644 --- a/docs/reference/lagmess.html +++ b/docs/reference/lagmess.html @@ -250,7 +250,7 @@

Examples

#> system.time(obj2 <- lagmess(log(PRICE) ~ PATIO + log(AGE) + log(SQFT), data=baltimore, listw=lw)) #> user system elapsed -#> 0.03 0.00 0.03 +#> 0.042 0.000 0.043 (x <- summary(obj2)) #> Matrix exponential spatial lag model: #> diff --git a/docs/reference/sparse_mat.html b/docs/reference/sparse_mat.html index 427107a..6e645cb 100644 --- a/docs/reference/sparse_mat.html +++ b/docs/reference/sparse_mat.html @@ -180,11 +180,11 @@

Examples

W <- as(lw, "CsparseMatrix") system.time(e <- invIrM(nb7rt, rho=0.98, method="solve", feasible=NULL) %*% x) #> user system elapsed -#> 0.002 0.000 0.002 +#> 0.003 0.000 0.003 system.time(ee <- powerWeights(W, rho=0.98, X=x)) #> Warning: not converged within order iterations #> user system elapsed -#> 0.181 0.010 0.192 +#> 0.241 0.001 0.246 str(attr(ee, "internal")) #> List of 5 #> $ series: num [1:250] 0.287 0.234 0.201 0.178 0.16 ... @@ -197,10 +197,10 @@

Examples

# \dontrun{ system.time(ee <- powerWeights(W, rho=0.9, X=x)) #> user system elapsed -#> 0.133 0.005 0.140 +#> 0.195 0.000 0.200 system.time(ee <- powerWeights(W, rho=0.98, order=1000, X=x)) #> user system elapsed -#> 0.769 0.008 0.782 +#> 0.860 0.000 0.868 all.equal(e, as(ee, "matrix"), check.attributes=FALSE) #> [1] TRUE nb60rt <- spdep::cell2nb(60, 60, torus=TRUE) @@ -209,16 +209,16 @@

Examples

x <- matrix(rnorm(dim(W)[1]), ncol=1) system.time(ee <- powerWeights(W, rho=0.3, X=x)) #> user system elapsed -#> 0.009 0.000 0.009 +#> 0.011 0.000 0.011 str(as(ee, "matrix")) #> num [1:3600, 1] -0.383 0.207 -0.731 1.552 0.32 ... #> - attr(*, "dimnames")=List of 2 #> ..$ : chr [1:3600] "1:1" "2:1" "3:1" "4:1" ... #> ..$ : NULL obj <- errorsarlm(as(ee, "matrix")[,1] ~ 1, listw=spdep::nb2listw(nb60rt), method="Matrix") -#> Error in errorsarlm(as(ee, "matrix")[, 1] ~ 1, listw = spdep::nb2listw(nb60rt), method = "Matrix"): argument "Durbin" is missing, with no default coefficients(obj) -#> Error in eval(expr, envir, enclos): object 'obj' not found +#> lambda (Intercept) +#> 0.30639880 0.01380415 # }

diff --git a/docs/reference/spautolm.html b/docs/reference/spautolm.html index 9f7edce..6695535 100644 --- a/docs/reference/spautolm.html +++ b/docs/reference/spautolm.html @@ -422,7 +422,7 @@

Examples

data=nydata, listw=listw_NY, family="SAR", method="eigen", control=list(pre_eig=eigs))) #> user system elapsed -#> 0.196 0.000 0.197 +#> 0.313 0.000 0.314 res <- summary(esar1f) print(res) #> @@ -467,7 +467,7 @@

Examples

system.time(esar1M <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, listw=listw_NY, family="SAR", method="Matrix")) #> user system elapsed -#> 0.221 0.000 0.221 +#> 0.426 0.000 0.458 summary(esar1M) #> #> Call: @@ -498,7 +498,7 @@

Examples

data=nydata, listw=listw_NY, family="SAR", method="Matrix", control=list(super=TRUE))) #> user system elapsed -#> 0.196 0.000 0.196 +#> 0.373 0.001 0.379 summary(esar1M) #> #> Call: @@ -558,7 +558,7 @@

Examples

system.time(esar1wM <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, listw=listw_NY, weights=POP8, family="SAR", method="Matrix")) #> user system elapsed -#> 0.212 0.000 0.214 +#> 0.382 0.000 0.385 summary(esar1wM) #> #> Call: @@ -675,7 +675,7 @@

Examples

system.time(ecar1M <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, listw=listw_NY, family="CAR", method="Matrix")) #> user system elapsed -#> 0.236 0.000 0.237 +#> 0.441 0.000 0.444 summary(ecar1M) #> #> Call: @@ -737,7 +737,7 @@

Examples

system.time(ecar1wM <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, listw=listw_NY, weights=POP8, family="CAR", method="Matrix")) #> user system elapsed -#> 0.243 0.000 0.244 +#> 0.437 0.001 0.456 summary(ecar1wM) #> #> Call: diff --git a/docs/reference/trW.html b/docs/reference/trW.html index 77af24b..89ade63 100644 --- a/docs/reference/trW.html +++ b/docs/reference/trW.html @@ -150,11 +150,11 @@

Examples

set.seed(1100) system.time(trMC <- trW(W, type="MC")) #> user system elapsed -#> 0.005 0.000 0.006 +#> 0.006 0.000 0.006 str(trMC) #> num [1:30] 0 10.91 3.69 5.36 3.64 ... #> - attr(*, "sd")= num [1:30] NA NA 0.598 0.495 0.489 ... -#> - attr(*, "timings")= Named num [1:2] 0.005 0.005 +#> - attr(*, "timings")= Named num [1:2] 0.006 0.006 #> ..- attr(*, "names")= chr [1:2] "user.self" "elapsed" #> - attr(*, "type")= chr "MC" #> - attr(*, "n")= int 49 @@ -169,10 +169,10 @@

Examples

W <- forceSymmetric(as(listwS, "CsparseMatrix")) system.time(trmom <- trW(listw=listwS, m=24, type="moments")) #> user system elapsed -#> 0.002 0.000 0.001 +#> 0.002 0.000 0.002 str(trmom) #> num [1:24] 0 10.91 3.65 5.62 3.66 ... -#> - attr(*, "timings")= Named num [1:2] 0.002 0.001 +#> - attr(*, "timings")= Named num [1:2] 0.002 0.002 #> ..- attr(*, "names")= chr [1:2] "user.self" "elapsed" #> - attr(*, "type")= chr "moments" #> - attr(*, "n")= int 49 @@ -180,10 +180,10 @@

Examples

#> [1] TRUE system.time(trMat <- trW(W, m=24, type="mult")) #> user system elapsed -#> 0.003 0.000 0.003 +#> 0.005 0.000 0.005 str(trMat) #> num [1:24] 0 10.91 3.65 5.62 3.66 ... -#> - attr(*, "timings")= Named num [1:2] 0.003 0.003 +#> - attr(*, "timings")= Named num [1:2] 0.005 0.005 #> ..- attr(*, "names")= chr [1:2] "user.self" "elapsed" #> - attr(*, "type")= chr "mult" #> - attr(*, "n")= int 49 @@ -192,11 +192,11 @@

Examples

set.seed(1) system.time(trMC <- trW(W, m=24, type="MC")) #> user system elapsed -#> 0.006 0.000 0.005 +#> 0.009 0.000 0.009 str(trMC) #> num [1:24] 0 10.91 2.44 4.97 2.82 ... #> - attr(*, "sd")= num [1:24] NA NA 0.618 0.501 0.451 ... -#> - attr(*, "timings")= Named num [1:2] 0.006 0.005 +#> - attr(*, "timings")= Named num [1:2] 0.008 0.009 #> ..- attr(*, "names")= chr [1:2] "user.self" "elapsed" #> - attr(*, "type")= chr "MC" #> - attr(*, "n")= int 49 @@ -206,10 +206,10 @@

Examples

listwS <- similar.listw(listw) system.time(trmom <- trW(listw=listwS, m=24, type="moments")) #> user system elapsed -#> 0.108 0.000 0.108 +#> 0.128 0.000 0.128 str(trmom) #> num [1:24] 0 124.2 32.7 63.7 33.2 ... -#> - attr(*, "timings")= Named num [1:2] 0.108 0.108 +#> - attr(*, "timings")= Named num [1:2] 0.128 0.128 #> ..- attr(*, "names")= chr [1:2] "user.self" "elapsed" #> - attr(*, "type")= chr "moments" #> - attr(*, "n")= int 506 @@ -225,7 +225,7 @@

Examples

} system.time(trmomp <- trW(listw=listwS, m=24, type="moments")) #> user system elapsed -#> 0.111 0.000 0.112 +#> 0.125 0.000 0.127 if(!get.mcOption()) { set.ClusterOption(NULL) stopCluster(cl)