diff --git a/docs/404.html b/docs/404.html index 366c8a6..7e41807 100644 --- a/docs/404.html +++ b/docs/404.html @@ -32,7 +32,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -106,7 +106,7 @@

Page not found (404)

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/articles/SpatialFiltering.html b/docs/articles/SpatialFiltering.html index 2a5d869..d2f66f1 100644 --- a/docs/articles/SpatialFiltering.html +++ b/docs/articles/SpatialFiltering.html @@ -33,7 +33,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -85,7 +85,8 @@
@@ -82,7 +82,7 @@

All vignettes

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/articles/nb_igraph.html b/docs/articles/nb_igraph.html index 625b50e..867c600 100644 --- a/docs/articles/nb_igraph.html +++ b/docs/articles/nb_igraph.html @@ -33,7 +33,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -84,8 +84,10 @@
@@ -1874,7 +1055,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/Rplot001.png b/docs/reference/Rplot001.png index 5fe2fe3..881792b 100644 Binary files a/docs/reference/Rplot001.png and b/docs/reference/Rplot001.png differ diff --git a/docs/reference/SET_MCMC.html b/docs/reference/SET_MCMC.html index c6e8af8..c63be90 100644 --- a/docs/reference/SET_MCMC.html +++ b/docs/reference/SET_MCMC.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -290,9 +290,6 @@

Examples

#require("spdep", quietly=TRUE)
 data(oldcol, package="spdep")
 lw <- spdep::nb2listw(COL.nb, style="W")
-ev <- eigenw(lw)
-W <- as(lw, "CsparseMatrix")
-trMatc <- trW(W, type="mult")
 require("coda", quietly=TRUE)
 set.seed(1)
 COL.err.Bayes <- spBreg_err(CRIME ~ INC + HOVAL, data=COL.OLD, listw=lw)
@@ -336,621 +333,65 @@ 

Examples

#> lambda 3 1010 937 1.080 #> sige 2 930 937 0.993 #> -# \dontrun{ +if (FALSE) { +ev <- eigenw(lw) +W <- as(lw, "CsparseMatrix") +trMatc <- trW(W, type="mult") set.seed(1) COL.err.Bayes <- spBreg_err(CRIME ~ INC + HOVAL, data=COL.OLD, listw=lw, control=list(prior=list(lambdaMH=TRUE))) print(summary(COL.err.Bayes)) -#> -#> Iterations = 501:2500 -#> Thinning interval = 1 -#> Number of chains = 1 -#> Sample size per chain = 2000 -#> -#> 1. Empirical mean and standard deviation for each variable, -#> plus standard error of the mean: -#> -#> Mean SD Naive SE Time-series SE -#> (Intercept) 59.5304 8.9916 0.201059 0.275885 -#> INC -0.9142 0.3969 0.008874 0.011266 -#> HOVAL -0.3027 0.1021 0.002282 0.002282 -#> lambda 0.6011 0.1502 0.003358 0.007723 -#> sige 116.6773 27.9707 0.625443 0.660902 -#> -#> 2. Quantiles for each variable: -#> -#> 2.5% 25% 50% 75% 97.5% -#> (Intercept) 44.0607 54.802 59.6796 64.2473 72.9189 -#> INC -1.6866 -1.184 -0.9177 -0.6422 -0.1429 -#> HOVAL -0.5102 -0.370 -0.3005 -0.2359 -0.1019 -#> lambda 0.2826 0.511 0.6135 0.7023 0.8676 -#> sige 74.1788 97.167 113.2955 130.2498 182.6024 -#> print(raftery.diag(COL.err.Bayes, r=0.01)) -#> -#> Quantile (q) = 0.025 -#> Accuracy (r) = +/- 0.01 -#> Probability (s) = 0.95 -#> -#> Burn-in Total Lower bound Dependence -#> (M) (N) (Nmin) factor (I) -#> (Intercept) 3 1143 937 1.220 -#> INC 2 969 937 1.030 -#> HOVAL 2 892 937 0.952 -#> lambda 17 4454 937 4.750 -#> sige 2 930 937 0.993 -#> set.seed(1) COL.err.Bayes <- spBreg_err(CRIME ~ INC + HOVAL, data=COL.OLD, listw=lw, Durbin=TRUE) print(summary(COL.err.Bayes)) -#> -#> Iterations = 501:2500 -#> Thinning interval = 1 -#> Number of chains = 1 -#> Sample size per chain = 2000 -#> -#> 1. Empirical mean and standard deviation for each variable, -#> plus standard error of the mean: -#> -#> Mean SD Naive SE Time-series SE -#> (Intercept) 72.66455 11.7701 0.263187 0.263187 -#> INC -1.01543 0.3763 0.008414 0.008414 -#> HOVAL -0.28060 0.1050 0.002347 0.002347 -#> lag.INC -1.06754 0.7388 0.016519 0.016519 -#> lag.HOVAL 0.08961 0.2383 0.005328 0.005328 -#> lambda 0.48878 0.1732 0.003873 0.003873 -#> sige 114.66234 26.8527 0.600444 0.659903 -#> -#> 2. Quantiles for each variable: -#> -#> 2.5% 25% 50% 75% 97.5% -#> (Intercept) 48.2182 65.57218 73.00283 80.0588 95.67986 -#> INC -1.7264 -1.27249 -1.01848 -0.7658 -0.26325 -#> HOVAL -0.4835 -0.35298 -0.27998 -0.2105 -0.07685 -#> lag.INC -2.4553 -1.54934 -1.08873 -0.6092 0.39927 -#> lag.HOVAL -0.3926 -0.06243 0.09177 0.2443 0.55929 -#> lambda 0.1165 0.37669 0.49775 0.6118 0.79690 -#> sige 73.4827 95.70364 110.68368 129.1459 177.97468 -#> print(summary(impacts(COL.err.Bayes))) -#> Impact measures (SDEM, MCMC, n): -#> Direct Indirect Total -#> INC -1.0154294 -1.06753527 -2.0829647 -#> HOVAL -0.2806034 0.08960515 -0.1909982 -#> ======================================================== -#> Standard errors: -#> Direct Indirect Total -#> INC 0.35656492 0.7000652 0.8257127 -#> HOVAL 0.09946104 0.2258118 0.2716818 -#> ======================================================== -#> Z-values: -#> Direct Indirect Total -#> INC -2.847811 -1.5249083 -2.5226265 -#> HOVAL -2.821239 0.3968134 -0.7030219 -#> -#> p-values: -#> Direct Indirect Total -#> INC 0.0044021 0.12728 0.011648 -#> HOVAL 0.0047839 0.69151 0.482042 -#> print(raftery.diag(COL.err.Bayes, r=0.01)) -#> -#> Quantile (q) = 0.025 -#> Accuracy (r) = +/- 0.01 -#> Probability (s) = 0.95 -#> -#> Burn-in Total Lower bound Dependence -#> (M) (N) (Nmin) factor (I) -#> (Intercept) 2 930 937 0.993 -#> INC 3 1010 937 1.080 -#> HOVAL 2 930 937 0.993 -#> lag.INC 2 892 937 0.952 -#> lag.HOVAL 2 892 937 0.952 -#> lambda 2 930 937 0.993 -#> sige 2 930 937 0.993 -#> set.seed(1) COL.err.Bayes <- spBreg_err(CRIME ~ INC + HOVAL, data=COL.OLD, listw=lw, Durbin=TRUE, control=list(prior=list(lambdaMH=TRUE))) print(summary(COL.err.Bayes)) -#> -#> Iterations = 501:2500 -#> Thinning interval = 1 -#> Number of chains = 1 -#> Sample size per chain = 2000 -#> -#> 1. Empirical mean and standard deviation for each variable, -#> plus standard error of the mean: -#> -#> Mean SD Naive SE Time-series SE -#> (Intercept) 70.40019 70.4345 1.574962 1.385430 -#> INC -0.97037 0.4110 0.009190 0.009823 -#> HOVAL -0.28455 0.1145 0.002561 0.002561 -#> lag.INC -0.95215 0.8426 0.018842 0.027001 -#> lag.HOVAL 0.06555 0.2679 0.005990 0.007555 -#> lambda 0.60702 0.1781 0.003983 0.014276 -#> sige 120.45188 29.1908 0.652727 1.279486 -#> -#> 2. Quantiles for each variable: -#> -#> 2.5% 25% 50% 75% 97.5% -#> (Intercept) 37.9440 62.5478 71.80756 80.9018 104.95272 -#> INC -1.7687 -1.2346 -0.98524 -0.7063 -0.14242 -#> HOVAL -0.5141 -0.3592 -0.28460 -0.2088 -0.06554 -#> lag.INC -2.6086 -1.5191 -0.95619 -0.4294 0.72268 -#> lag.HOVAL -0.4869 -0.1027 0.06799 0.2443 0.56913 -#> lambda 0.2366 0.5043 0.62080 0.7333 0.92570 -#> sige 76.7686 99.6498 116.80421 135.9061 189.12857 -#> print(summary(impacts(COL.err.Bayes))) -#> Impact measures (SDEM, MCMC, n): -#> Direct Indirect Total -#> INC -0.9703690 -0.95214894 -1.9225179 -#> HOVAL -0.2845537 0.06555386 -0.2189999 -#> ======================================================== -#> Standard errors: -#> Direct Indirect Total -#> INC 0.3894378 0.7984944 0.9933065 -#> HOVAL 0.1085247 0.2538476 0.3175629 -#> ======================================================== -#> Z-values: -#> Direct Indirect Total -#> INC -2.491717 -1.192430 -1.9354730 -#> HOVAL -2.622018 0.258241 -0.6896269 -#> -#> p-values: -#> Direct Indirect Total -#> INC 0.0127127 0.23309 0.052932 -#> HOVAL 0.0087411 0.79622 0.490429 -#> print(raftery.diag(COL.err.Bayes, r=0.01)) -#> -#> Quantile (q) = 0.025 -#> Accuracy (r) = +/- 0.01 -#> Probability (s) = 0.95 -#> -#> Burn-in Total Lower bound Dependence -#> (M) (N) (Nmin) factor (I) -#> (Intercept) 5 1472 937 1.570 -#> INC 2 892 937 0.952 -#> HOVAL 3 1010 937 1.080 -#> lag.INC 3 1010 937 1.080 -#> lag.HOVAL 2 930 937 0.993 -#> lambda 14 3645 937 3.890 -#> sige 2 930 937 0.993 -#> set.seed(1) COL.err.Bayes <- spBreg_err(CRIME ~ INC + HOVAL, data=COL.OLD, listw=lw, Durbin=~INC) print(summary(COL.err.Bayes)) -#> -#> Iterations = 501:2500 -#> Thinning interval = 1 -#> Number of chains = 1 -#> Sample size per chain = 2000 -#> -#> 1. Empirical mean and standard deviation for each variable, -#> plus standard error of the mean: -#> -#> Mean SD Naive SE Time-series SE -#> (Intercept) 74.5423 10.98931 0.245728 0.245728 -#> INC -1.0339 0.38293 0.008563 0.008987 -#> HOVAL -0.2860 0.09857 0.002204 0.002204 -#> lag.INC -0.9190 0.59170 0.013231 0.012507 -#> lambda 0.4879 0.17196 0.003845 0.003672 -#> sige 112.0658 25.47022 0.569531 0.567228 -#> -#> 2. Quantiles for each variable: -#> -#> 2.5% 25% 50% 75% 97.5% -#> (Intercept) 52.0905 67.8363 74.9216 81.7016 94.97558 -#> INC -1.7796 -1.2965 -1.0425 -0.7816 -0.23925 -#> HOVAL -0.4762 -0.3494 -0.2861 -0.2205 -0.08885 -#> lag.INC -2.0736 -1.3191 -0.9217 -0.5457 0.27871 -#> lambda 0.1355 0.3737 0.4987 0.6088 0.80100 -#> sige 73.0813 94.1656 108.2980 125.8857 173.13082 -#> print(summary(impacts(COL.err.Bayes))) -#> Impact measures (SDEM, MCMC, n): -#> Direct Indirect Total -#> INC -1.0339443 -0.9190497 -1.9529940 -#> HOVAL -0.2860029 NA -0.2860029 -#> ======================================================== -#> Standard errors: -#> Direct Indirect Total -#> INC 0.36696535 0.5670367 0.69945670 -#> HOVAL 0.09446444 NA 0.09446444 -#> ======================================================== -#> Z-values: -#> Direct Indirect Total -#> INC -2.817553 -1.620794 -2.792159 -#> HOVAL -3.027625 NA -3.027625 -#> -#> p-values: -#> Direct Indirect Total -#> INC 0.0048391 0.10506 0.0052358 -#> HOVAL 0.0024648 NA 0.0024648 -#> print(raftery.diag(COL.err.Bayes, r=0.01)) -#> -#> Quantile (q) = 0.025 -#> Accuracy (r) = +/- 0.01 -#> Probability (s) = 0.95 -#> -#> Burn-in Total Lower bound Dependence -#> (M) (N) (Nmin) factor (I) -#> (Intercept) 3 1010 937 1.080 -#> INC 2 892 937 0.952 -#> HOVAL 2 930 937 0.993 -#> lag.INC 2 892 937 0.952 -#> lambda 2 892 937 0.952 -#> sige 3 1010 937 1.080 -#> set.seed(1) COL.err.Bayes <- spBreg_err(CRIME ~ INC + HOVAL, data=COL.OLD, listw=lw, Durbin=~INC, control=list(prior=list(lambdaMH=TRUE))) print(summary(COL.err.Bayes)) -#> -#> Iterations = 501:2500 -#> Thinning interval = 1 -#> Number of chains = 1 -#> Sample size per chain = 2000 -#> -#> 1. Empirical mean and standard deviation for each variable, -#> plus standard error of the mean: -#> -#> Mean SD Naive SE Time-series SE -#> (Intercept) 72.8864 13.2070 0.295318 0.332323 -#> INC -0.9843 0.3831 0.008566 0.009768 -#> HOVAL -0.2889 0.1008 0.002253 0.002253 -#> lag.INC -0.8606 0.6640 0.014847 0.014847 -#> lambda 0.5779 0.1662 0.003715 0.010526 -#> sige 114.9801 26.2240 0.586387 0.665850 -#> -#> 2. Quantiles for each variable: -#> -#> 2.5% 25% 50% 75% 97.5% -#> (Intercept) 45.5280 65.3717 73.3929 81.2895 97.2255 -#> INC -1.7170 -1.2373 -0.9898 -0.7261 -0.2197 -#> HOVAL -0.4870 -0.3565 -0.2850 -0.2177 -0.1032 -#> lag.INC -2.1579 -1.2914 -0.8847 -0.4386 0.4898 -#> lambda 0.2436 0.4725 0.5835 0.6981 0.8672 -#> sige 73.5737 96.1297 111.5039 130.5606 176.0332 -#> print(summary(impacts(COL.err.Bayes))) -#> Impact measures (SDEM, MCMC, n): -#> Direct Indirect Total -#> INC -0.9843411 -0.8605551 -1.8448962 -#> HOVAL -0.2889068 NA -0.2889068 -#> ======================================================== -#> Standard errors: -#> Direct Indirect Total -#> INC 0.36712699 0.6362974 0.80457985 -#> HOVAL 0.09657666 NA 0.09657666 -#> ======================================================== -#> Z-values: -#> Direct Indirect Total -#> INC -2.681201 -1.352442 -2.292993 -#> HOVAL -2.991476 NA -2.991476 -#> -#> p-values: -#> Direct Indirect Total -#> INC 0.0073359 0.17623 0.0218484 -#> HOVAL 0.0027763 NA 0.0027763 -#> print(raftery.diag(COL.err.Bayes, r=0.01)) -#> -#> Quantile (q) = 0.025 -#> Accuracy (r) = +/- 0.01 -#> Probability (s) = 0.95 -#> -#> Burn-in Total Lower bound Dependence -#> (M) (N) (Nmin) factor (I) -#> (Intercept) 4 1192 937 1.270 -#> INC 2 892 937 0.952 -#> HOVAL 2 930 937 0.993 -#> lag.INC 2 892 937 0.952 -#> lambda 10 2853 937 3.040 -#> sige 2 930 937 0.993 -#> set.seed(1) COL.sacW.B0 <- spBreg_sac(CRIME ~ INC + HOVAL, data=COL.OLD, listw=lw, Durbin=FALSE, control=list(ndraw=1500L, nomit=500L)) print(summary(COL.sacW.B0)) -#> -#> Iterations = 501:1500 -#> Thinning interval = 1 -#> Number of chains = 1 -#> Sample size per chain = 1000 -#> -#> 1. Empirical mean and standard deviation for each variable, -#> plus standard error of the mean: -#> -#> Mean SD Naive SE Time-series SE -#> (Intercept) 49.3672 9.23725 0.292108 0.847100 -#> INC -0.9925 0.35777 0.011314 0.012624 -#> HOVAL -0.2847 0.09798 0.003099 0.003307 -#> rho 0.3117 0.19633 0.006208 0.020392 -#> lambda 0.1927 0.27130 0.008579 0.027162 -#> sige 105.0462 23.96805 0.757936 0.757936 -#> -#> 2. Quantiles for each variable: -#> -#> 2.5% 25% 50% 75% 97.5% -#> (Intercept) 31.8783 43.12583 48.9398 55.3573 68.1858 -#> INC -1.6817 -1.24459 -0.9872 -0.7516 -0.3168 -#> HOVAL -0.4952 -0.34433 -0.2827 -0.2201 -0.1028 -#> rho -0.1548 0.21285 0.3406 0.4438 0.6176 -#> lambda -0.3788 0.01455 0.2171 0.3794 0.6988 -#> sige 68.5025 88.13909 101.6888 118.2545 160.2792 -#> print(summary(impacts(COL.sacW.B0, tr=trMatc), zstats=TRUE, short=TRUE)) -#> Impact measures (sac, trace): -#> Direct Indirect Total -#> INC -1.017325 -0.4246675 -1.4419930 -#> HOVAL -0.291816 -0.1218143 -0.4136303 -#> ======================================================== -#> Simulation results ( variance matrix): -#> ======================================================== -#> Simulated standard errors -#> Direct Indirect Total -#> INC 0.3668822 0.4180525 0.6533395 -#> HOVAL 0.1016518 0.1341689 0.1983041 -#> -#> Simulated z-values: -#> Direct Indirect Total -#> INC -2.808257 -1.219897 -2.357550 -#> HOVAL -2.910868 -1.106171 -2.240542 -#> -#> Simulated p-values: -#> Direct Indirect Total -#> INC 0.0049810 0.22250 0.018396 -#> HOVAL 0.0036043 0.26865 0.025056 set.seed(1) COL.sacW.B1 <- spBreg_sac(CRIME ~ INC + HOVAL, data=COL.OLD, listw=lw, Durbin=TRUE, control=list(ndraw=1500L, nomit=500L)) print(summary(COL.sacW.B1)) -#> -#> Iterations = 501:1500 -#> Thinning interval = 1 -#> Number of chains = 1 -#> Sample size per chain = 1000 -#> -#> 1. Empirical mean and standard deviation for each variable, -#> plus standard error of the mean: -#> -#> Mean SD Naive SE Time-series SE -#> (Intercept) 60.1833 24.14827 0.763635 3.169760 -#> INC -0.9880 0.36251 0.011464 0.015819 -#> HOVAL -0.2839 0.09749 0.003083 0.003433 -#> lag.INC -0.8740 0.77272 0.024435 0.061565 -#> lag.HOVAL 0.1704 0.22184 0.007015 0.013821 -#> rho 0.1808 0.32007 0.010121 0.044327 -#> lambda 0.2106 0.32071 0.010142 0.041657 -#> sige 100.9463 24.32264 0.769149 0.946662 -#> -#> 2. Quantiles for each variable: -#> -#> 2.5% 25% 50% 75% 97.5% -#> (Intercept) 22.2042 42.277313 56.1007 76.4887 113.5316 -#> INC -1.7045 -1.223372 -0.9842 -0.7329 -0.3299 -#> HOVAL -0.4803 -0.349479 -0.2841 -0.2152 -0.1085 -#> lag.INC -2.5306 -1.336778 -0.8386 -0.3451 0.5156 -#> lag.HOVAL -0.3031 0.026900 0.1851 0.3249 0.5752 -#> rho -0.5076 -0.021227 0.2386 0.4320 0.6655 -#> lambda -0.5106 -0.007594 0.2129 0.4482 0.7389 -#> sige 64.6867 84.395156 96.9599 114.4101 159.7252 -#> print(summary(impacts(COL.sacW.B1, tr=trMatc), zstats=TRUE, short=TRUE)) -#> Impact measures (sacmixed, trace): -#> Direct Indirect Total -#> INC -1.0332779 -1.239705 -2.2729830 -#> HOVAL -0.2787547 0.140259 -0.1384957 -#> ======================================================== -#> Simulation results ( variance matrix): -#> ======================================================== -#> Simulated standard errors -#> Direct Indirect Total -#> INC 0.3510687 0.9383466 1.0337787 -#> HOVAL 0.1002385 0.2776460 0.3184971 -#> -#> Simulated z-values: -#> Direct Indirect Total -#> INC -2.962199 -1.4351185 -2.3085930 -#> HOVAL -2.775887 0.5415921 -0.4015108 -#> -#> Simulated p-values: -#> Direct Indirect Total -#> INC 0.0030545 0.15125 0.020966 -#> HOVAL 0.0055051 0.58810 0.688044 set.seed(1) COL.lag.Bayes <- spBreg_lag(CRIME ~ INC + HOVAL, data=COL.OLD, listw=lw) print(summary(COL.lag.Bayes)) -#> -#> Iterations = 501:2500 -#> Thinning interval = 1 -#> Number of chains = 1 -#> Sample size per chain = 2000 -#> -#> 1. Empirical mean and standard deviation for each variable, -#> plus standard error of the mean: -#> -#> Mean SD Naive SE Time-series SE -#> (Intercept) 45.8256 8.04911 0.179984 0.179984 -#> INC -1.0459 0.34746 0.007770 0.007770 -#> HOVAL -0.2662 0.09366 0.002094 0.002094 -#> rho 0.4146 0.12434 0.002780 0.002780 -#> sige 107.8827 23.75095 0.531087 0.561152 -#> -#> 2. Quantiles for each variable: -#> -#> 2.5% 25% 50% 75% 97.5% -#> (Intercept) 30.3334 40.3140 45.9376 51.0903 61.51008 -#> INC -1.7252 -1.2774 -1.0477 -0.8158 -0.35423 -#> HOVAL -0.4533 -0.3312 -0.2686 -0.2019 -0.08107 -#> rho 0.1645 0.3327 0.4157 0.5008 0.64982 -#> sige 70.5778 90.6316 104.8556 120.4706 164.75421 -#> print(summary(impacts(COL.lag.Bayes, tr=trMatc), short=TRUE, zstats=TRUE)) -#> Impact measures (lag, trace): -#> Direct Indirect Total -#> INC -1.0962113 -0.6903627 -1.7865741 -#> HOVAL -0.2790451 -0.1757347 -0.4547797 -#> ======================================================== -#> Simulation results ( variance matrix): -#> ======================================================== -#> Simulated standard errors -#> Direct Indirect Total -#> INC 0.3680189 0.4927553 0.7674941 -#> HOVAL 0.1002735 0.1393959 0.2171077 -#> -#> Simulated z-values: -#> Direct Indirect Total -#> INC -3.003178 -1.554252 -2.437925 -#> HOVAL -2.809370 -1.425055 -2.212507 -#> -#> Simulated p-values: -#> Direct Indirect Total -#> INC 0.0026718 0.12012 0.014772 -#> HOVAL 0.0049639 0.15414 0.026932 print(summary(impacts(COL.lag.Bayes, evalues=ev), short=TRUE, zstats=TRUE)) -#> Impact measures (lag, evalues): -#> Direct Indirect Total -#> INC -1.0962113 -0.6903627 -1.7865741 -#> HOVAL -0.2790451 -0.1757347 -0.4547797 -#> ======================================================== -#> Simulation results ( variance matrix): -#> ======================================================== -#> Simulated standard errors -#> Direct Indirect Total -#> INC 0.3680193 0.4929524 0.7676307 -#> HOVAL 0.1002746 0.1395496 0.2172252 -#> -#> Simulated z-values: -#> Direct Indirect Total -#> INC -3.003178 -1.553686 -2.437527 -#> HOVAL -2.809345 -1.423571 -2.211367 -#> -#> Simulated p-values: -#> Direct Indirect Total -#> INC 0.0026718 0.12026 0.014788 -#> HOVAL 0.0049642 0.15457 0.027010 set.seed(1) COL.D0.Bayes <- spBreg_lag(CRIME ~ INC + HOVAL, data=COL.OLD, listw=lw, Durbin=TRUE) print(summary(COL.D0.Bayes)) -#> -#> Iterations = 501:2500 -#> Thinning interval = 1 -#> Number of chains = 1 -#> Sample size per chain = 2000 -#> -#> 1. Empirical mean and standard deviation for each variable, -#> plus standard error of the mean: -#> -#> Mean SD Naive SE Time-series SE -#> (Intercept) 45.3106 13.74660 0.307383 0.307383 -#> INC -0.9255 0.36779 0.008224 0.008224 -#> HOVAL -0.2941 0.09628 0.002153 0.002153 -#> lag.INC -0.5834 0.63860 0.014279 0.014279 -#> lag.HOVAL 0.2396 0.19206 0.004295 0.004295 -#> rho 0.3932 0.16296 0.003644 0.003644 -#> sige 109.7428 24.97328 0.558419 0.607251 -#> -#> 2. Quantiles for each variable: -#> -#> 2.5% 25% 50% 75% 97.5% -#> (Intercept) 19.18523 35.9952 45.0347 54.5253 72.8545 -#> INC -1.63995 -1.1761 -0.9206 -0.6651 -0.2148 -#> HOVAL -0.48230 -0.3566 -0.2931 -0.2308 -0.1021 -#> lag.INC -1.82283 -1.0066 -0.5712 -0.1763 0.6692 -#> lag.HOVAL -0.14391 0.1068 0.2393 0.3670 0.6168 -#> rho 0.06053 0.2826 0.3977 0.5078 0.6949 -#> sige 71.19421 91.4872 106.1690 123.7826 170.9503 -#> print(summary(impacts(COL.D0.Bayes, tr=trMatc), short=TRUE, zstats=TRUE)) -#> Impact measures (mixed, trace): -#> Direct Indirect Total -#> INC -1.027773 -1.4589793 -2.48675192 -#> HOVAL -0.280732 0.1908138 -0.08991828 -#> ======================================================== -#> Simulation results ( variance matrix): -#> ======================================================== -#> Simulated standard errors -#> Direct Indirect Total -#> INC 0.38264314 1.3114491 1.4534522 -#> HOVAL 0.09937135 0.3347428 0.3698437 -#> -#> Simulated z-values: -#> Direct Indirect Total -#> INC -2.739321 -1.2582210 -1.8564594 -#> HOVAL -2.838369 0.5610536 -0.2548209 -#> -#> Simulated p-values: -#> Direct Indirect Total -#> INC 0.0061566 0.20831 0.063388 -#> HOVAL 0.0045345 0.57476 0.798861 set.seed(1) COL.D1.Bayes <- spBreg_lag(CRIME ~ DISCBD + INC + HOVAL, data=COL.OLD, listw=lw, Durbin= ~ INC) print(summary(COL.D1.Bayes)) -#> -#> Iterations = 501:2500 -#> Thinning interval = 1 -#> Number of chains = 1 -#> Sample size per chain = 2000 -#> -#> 1. Empirical mean and standard deviation for each variable, -#> plus standard error of the mean: -#> -#> Mean SD Naive SE Time-series SE -#> (Intercept) 56.4447 13.43635 0.300446 0.300446 -#> DISCBD -4.7748 2.14395 0.047940 0.047940 -#> INC -0.9493 0.34681 0.007755 0.007755 -#> HOVAL -0.1798 0.09983 0.002232 0.002232 -#> lag.INC 0.4262 0.63352 0.014166 0.014166 -#> rho 0.1873 0.18174 0.004064 0.004064 -#> sige 103.8701 23.29384 0.520866 0.566802 -#> -#> 2. Quantiles for each variable: -#> -#> 2.5% 25% 50% 75% 97.5% -#> (Intercept) 30.5093 47.769573 56.4789 65.0877 84.86254 -#> DISCBD -9.2416 -6.153288 -4.7453 -3.3591 -0.67219 -#> INC -1.6655 -1.174948 -0.9451 -0.7102 -0.28365 -#> HOVAL -0.3744 -0.247270 -0.1775 -0.1128 0.01524 -#> lag.INC -0.8028 0.004752 0.4224 0.8433 1.66618 -#> rho -0.2116 0.072536 0.1836 0.3067 0.53579 -#> sige 67.8946 87.054945 100.9815 116.4528 161.25826 -#> print(summary(impacts(COL.D1.Bayes, tr=trMatc), short=TRUE, zstats=TRUE)) -#> Impact measures (mixed, trace): -#> Direct Indirect Total -#> DISCBD -4.8148501 -1.06067837 -5.8755285 -#> INC -0.9381442 0.29454370 -0.6436005 -#> HOVAL -0.1813164 -0.03994275 -0.2212591 -#> ======================================================== -#> Simulation results ( variance matrix): -#> ======================================================== -#> Simulated standard errors -#> Direct Indirect Total -#> DISCBD 2.1926383 1.82145831 3.3798560 -#> INC 0.3502903 0.81693522 0.8950370 -#> HOVAL 0.1015612 0.06692703 0.1429623 -#> -#> Simulated z-values: -#> Direct Indirect Total -#> DISCBD -2.219068 -0.7449248 -1.8410439 -#> INC -2.696796 0.3333552 -0.7511779 -#> HOVAL -1.802805 -0.7412143 -1.6277185 -#> -#> Simulated p-values: -#> Direct Indirect Total -#> DISCBD 0.026482 0.45632 0.065615 -#> INC 0.007001 0.73887 0.452546 -#> HOVAL 0.071419 0.45856 0.103585 #data(elect80, package="spData") #lw <- spdep::nb2listw(e80_queen, zero.policy=TRUE) #el_ml <- lagsarlm(log(pc_turnout) ~ log(pc_college) + log(pc_homeownership) @@ -962,7 +403,7 @@

Examples

#print(summary(el_B)) #print(el_ml$timings) #print(attr(el_B, "timings")) -# } +}
@@ -977,7 +418,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/SLX.html b/docs/reference/SLX.html index bdadaf2..698dc47 100644 --- a/docs/reference/SLX.html +++ b/docs/reference/SLX.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -69,8 +69,8 @@

Spatial Durbin linear (SLX, spatially lagged X) model

-
lmSLX(formula, data = list(), listw, na.action, weights=NULL,
- Durbin=TRUE, zero.policy=NULL)
+    
lmSLX(formula, data = list(), listw, na.action, weights=NULL, Durbin=TRUE,
+ zero.policy=NULL)
 create_WX(x, listw, zero.policy=NULL, prefix="")
 # S3 method for SlX
 impacts(obj, ...)
@@ -106,8 +106,7 @@ 

Arguments

default TRUE for lmSLX (Durbin model including WX); if TRUE, full spatial Durbin model; if a formula object, the subset of explanatory variables to lag

zero.policy
-

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

+

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

obj

A spatial regression object created by lmSLX

@@ -174,7 +173,7 @@

Examples

#> F-statistic: 17.12 on 4 and 44 DF, p-value: 1.553e-08 #> summary(impacts(COL.SLX)) -#> Impact measures (SlX, estimable, n-k): +#> Impact measures (SlX, glht, n-k): #> Direct Indirect Total #> INC -1.1089293 -1.3709725 -2.47990173 #> HOVAL -0.2897283 0.1917608 -0.09796753 @@ -196,7 +195,7 @@

Examples

#> COL.SLX <- lmSLX(CRIME ~ INC + HOVAL + I(HOVAL^2), data=COL.OLD, listw=lw, Durbin=TRUE) summary(impacts(COL.SLX)) -#> Impact measures (SlX, estimable, n-k): +#> Impact measures (SlX, glht, n-k): #> Direct Indirect Total #> INC -0.947594274 -1.275338647 -2.22293292 #> HOVAL -0.777427839 -0.355048446 -1.13247628 @@ -248,7 +247,7 @@

Examples

#> COL.SLX <- lmSLX(CRIME ~ INC + HOVAL + I(HOVAL^2), data=COL.OLD, listw=lw, Durbin=~INC) summary(impacts(COL.SLX)) -#> Impact measures (SlX, estimable, n-k): +#> Impact measures (SlX, glht, n-k): #> Direct Indirect Total #> INC -1.079064628 -1.010896 -2.089960575 #> HOVAL -0.634518755 NA -0.634518755 @@ -320,7 +319,7 @@

Examples

#> F-statistic: 26.49 on 2 and 46 DF, p-value: 2.214e-08 #> summary(impacts(COL.SLX)) -#> Impact measures (SlX, estimable, n-k): +#> Impact measures (SlX, glht, n-k): #> Direct Indirect Total #> INC -1.588901 -1.085867 -2.674768 #> ======================================================== @@ -336,7 +335,7 @@

Examples

#> Direct Indirect Total #> INC 8.2671e-06 0.024029 5.1387e-11 #> -# \dontrun{ +if (FALSE) { crds <- cbind(COL.OLD$X, COL.OLD$Y) mdist <- sqrt(sum(diff(apply(crds, 2, range))^2)) dnb <- spdep::dnearneigh(crds, 0, mdist) @@ -350,66 +349,12 @@

Examples

} opt <- optimize(f, interval=c(0.1, 4), form=CRIME ~ INC + HOVAL, data=COL.OLD, dnb=dnb, dists=dists, verbose=TRUE, maximum=TRUE) -#> power: 1.589667 logLik: -172.6864 -#> power: 2.510333 logLik: -177.741 -#> power: 1.020665 logLik: -171.5379 -#> power: 0.8721475 logLik: -171.7979 -#> power: 1.11302 logLik: -171.4973 -#> power: 1.107329 logLik: -171.497 -#> power: 1.105705 logLik: -171.497 -#> power: 1.105746 logLik: -171.497 -#> power: 1.105664 logLik: -171.497 -#> power: 1.105705 logLik: -171.497 glst <- lapply(dists, function(d) 1/(d^opt$maximum)) lw <- spdep::nb2listw(dnb, glist=glst, style="B") SLX <- lmSLX(CRIME ~ INC + HOVAL, data=COL.OLD, listw=lw) summary(SLX) -#> -#> Call: -#> lm(formula = formula(paste("y ~ ", paste(colnames(x)[-1], collapse = "+"))), -#> data = as.data.frame(x), weights = weights) -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -25.1535 -4.7529 -0.9819 4.8053 22.2274 -#> -#> Coefficients: -#> Estimate Std. Error t value Pr(>|t|) -#> (Intercept) 18.78498 11.23795 1.672 0.1019 -#> INC -0.65428 0.29463 -2.221 0.0317 * -#> HOVAL -0.18244 0.08138 -2.242 0.0302 * -#> lag..Intercept. 6.27790 4.44284 1.413 0.1648 -#> lag.INC -0.12958 0.28794 -0.450 0.6550 -#> lag.HOVAL 0.02668 0.11273 0.237 0.8141 -#> --- -#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 -#> -#> Residual standard error: 8.553 on 43 degrees of freedom -#> Multiple R-squared: 0.7659, Adjusted R-squared: 0.7387 -#> F-statistic: 28.14 on 5 and 43 DF, p-value: 1.544e-12 -#> summary(impacts(SLX)) -#> Impact measures (SlX, estimable, n-k): -#> Direct Indirect Total -#> INC -0.6542760 -0.12957739 -0.7838534 -#> HOVAL -0.1824383 0.02667561 -0.1557627 -#> ======================================================== -#> Standard errors: -#> Direct Indirect Total -#> INC 0.29463342 0.2879383 0.3742251 -#> HOVAL 0.08138257 0.1127279 0.1404591 -#> ======================================================== -#> Z-values: -#> Direct Indirect Total -#> INC -2.220644 -0.4500179 -2.094604 -#> HOVAL -2.241736 0.2366371 -1.108954 -#> -#> p-values: -#> Direct Indirect Total -#> INC 0.026375 0.65270 0.036206 -#> HOVAL 0.024978 0.81294 0.267450 -#> -# } +} COL.SLX <- lmSLX(CRIME ~ INC + HOVAL, data=COL.OLD, listw=lw) pslx0 <- predict(COL.SLX) pslx1 <- predict(COL.SLX, newdata=COL.OLD, listw=lw) @@ -419,9 +364,9 @@

Examples

COL.OLD1$INC <- COL.OLD1$INC + 1 pslx2 <- predict(COL.SLX, newdata=COL.OLD1, listw=lw) sum(coef(COL.SLX)[c(2,4)]) -#> [1] 5.623621 +#> [1] -2.479902 mean(pslx2-pslx1) -#> [1] -1.425045 +#> [1] -2.479902
@@ -436,7 +381,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/SpatialFiltering.html b/docs/reference/SpatialFiltering.html index 304f392..0438ab7 100644 --- a/docs/reference/SpatialFiltering.html +++ b/docs/reference/SpatialFiltering.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -198,8 +198,8 @@

Examples

#> 1 30.34786 #> 2 19.13010 #> 3 -18.12234 -#> 4 19.19379 -#> 5 22.99586 +#> 4 -19.19379 +#> 5 -22.99586 #> 6 17.12127 #> 7 11.66487 lmsar <- lm(CRIME ~ INC + HOVAL + fitted(sarcol), data=columbus) @@ -220,8 +220,8 @@

Examples

#> fitted(sarcol)vec5 30.34786 8.87679 3.419 0.00149 ** #> fitted(sarcol)vec3 19.13010 8.87679 2.155 0.03739 * #> fitted(sarcol)vec1 -18.12234 8.87679 -2.042 0.04800 * -#> fitted(sarcol)vec10 19.19379 8.87679 2.162 0.03679 * -#> fitted(sarcol)vec14 22.99586 8.87679 2.591 0.01341 * +#> fitted(sarcol)vec10 -19.19379 8.87679 -2.162 0.03679 * +#> fitted(sarcol)vec14 -22.99586 8.87679 -2.591 0.01341 * #> fitted(sarcol)vec11 17.12127 8.87679 1.929 0.06106 . #> fitted(sarcol)vec2 11.66487 8.87679 1.314 0.19649 #> --- @@ -239,8 +239,8 @@

Examples

#> fitted(sarcol)vec5 30.3478552 8.87679493 3.418785 1.486164e-03 #> fitted(sarcol)vec3 19.1300996 8.87679493 2.155068 3.738943e-02 #> fitted(sarcol)vec1 -18.1223409 8.87679493 -2.041541 4.800339e-02 -#> fitted(sarcol)vec10 19.1937947 8.87679493 2.162244 3.679422e-02 -#> fitted(sarcol)vec14 22.9958588 8.87679493 2.590559 1.340783e-02 +#> fitted(sarcol)vec10 -19.1937947 8.87679493 -2.162244 3.679422e-02 +#> fitted(sarcol)vec14 -22.9958588 8.87679493 -2.590559 1.340783e-02 #> fitted(sarcol)vec11 17.1212741 8.87679493 1.928768 6.106079e-02 #> fitted(sarcol)vec2 11.6648669 8.87679493 1.314085 1.964945e-01 anova(lmbase, lmsar) @@ -342,6 +342,7 @@

Examples

NA.columbus$CRIME[20:25] <- NA COL.SF.NA <- SpatialFiltering(CRIME ~ INC + HOVAL, data=NA.columbus, nb=col.gal.nb, style="W", na.action=na.exclude) +#> Warning: subsetting caused increase in subgraph count COL.SF.NA$na.action #> 20 21 22 23 24 25 #> 20 21 22 23 24 25 @@ -388,7 +389,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/aple.html b/docs/reference/aple.html index d1d1b56..398ac03 100644 --- a/docs/reference/aple.html +++ b/docs/reference/aple.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -114,7 +114,6 @@

See also

Examples

wheat <- st_read(system.file("shapes/wheat.shp", package="spData")[1], quiet=TRUE)
 library(spdep)
-#> Loading required package: sp
 #> 
 #> Attaching package: ‘spdep’
 #> The following objects are masked from ‘package:spatialreg’:
@@ -148,20 +147,9 @@ 

Examples

#> aple(as.vector(scale(wheat$yield_detrend, scale=FALSE)), spdep::nb2listw(nbr12, style="W")) #> [1] 0.6601805 -# \dontrun{ +if (FALSE) { errorsarlm(yield_detrend ~ 1, wheat, spdep::nb2listw(nbr12, style="W")) -#> -#> Call: -#> errorsarlm(formula = yield_detrend ~ 1, data = wheat, listw = spdep::nb2listw(nbr12, -#> style = "W")) -#> Type: error -#> -#> Coefficients: -#> lambda (Intercept) -#> 0.60189686 -0.00251772 -#> -#> Log likelihood: -192.9519 -# } +}
@@ -176,7 +164,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/aple.mc.html b/docs/reference/aple.mc.html index 3461338..ad8e8c8 100644 --- a/docs/reference/aple.mc.html +++ b/docs/reference/aple.mc.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -111,7 +111,7 @@

See also

Examples

-
# \dontrun{
+    
if (FALSE) {
 wheat <- st_read(system.file("shapes/wheat.shp", package="spData")[1], quiet=TRUE)
 nbr1 <- spdep::poly2nb(wheat, queen=FALSE)
 nbrl <- spdep::nblag(nbr1, 2)
@@ -127,23 +127,10 @@ 

Examples

boot_out_ser <- aple.mc(as.vector(scale(wheat$yield_detrend, scale=FALSE)), spdep::nb2listw(nbr12, style="W"), nsim=500) plot(boot_out_ser) - boot_out_ser -#> -#> DATA PERMUTATION -#> -#> -#> Call: -#> boot(data = x, statistic = aple.boot, R = nsim, sim = "permutation", -#> pre = pre, parallel = parallel, ncpus = ncpus, cl = cl) -#> -#> -#> Bootstrap Statistics : -#> original bias std. error -#> t1* 0.6601805 -0.6708415 0.1092922 library(parallel) oldCores <- set.coresOption(NULL) -nc <- detectCores(logical=FALSE) +nc <- max(2L, detectCores(logical=FALSE), na.rm = TRUE)-1L # set nc to 1L here if (nc > 1L) nc <- 1L invisible(set.coresOption(nc)) @@ -161,21 +148,9 @@

Examples

stopCluster(cl) } boot_out_par -#> -#> DATA PERMUTATION -#> -#> -#> Call: -#> boot(data = x, statistic = aple.boot, R = nsim, sim = "permutation", -#> pre = pre, parallel = parallel, ncpus = ncpus, cl = cl) -#> -#> -#> Bootstrap Statistics : -#> original bias std. error -#> t1* 0.6601805 -0.6708415 0.1092922 invisible(set.coresOption(oldCores)) RNGkind(oldRNG[1], oldRNG[2]) -# } +}
@@ -190,7 +165,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/aple.plot.html b/docs/reference/aple.plot.html index 804a4c1..f792cb2 100644 --- a/docs/reference/aple.plot.html +++ b/docs/reference/aple.plot.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -127,7 +127,7 @@

See also

Examples

-
# \dontrun{
+    
if (FALSE) {
 wheat <- st_read(system.file("shapes/wheat.shp", package="spData")[1], quiet=TRUE)
 nbr1 <- spdep::poly2nb(wheat, queen=FALSE)
 nbrl <- spdep::nblag(nbr1, 2)
@@ -141,72 +141,18 @@ 

Examples

abline(lm_obj) abline(v=0, h=0, lty=2) zz <- summary(influence.measures(lm_obj)) -#> Potentially influential observations of -#> lm(formula = Y ~ X, data = plt_out) : -#> -#> dfb.1_ dfb.X dffit cov.r cook.d hat -#> 34 -0.12 0.01 -0.12 0.98_* 0.01 0.00 -#> 50 0.10 0.01 0.11 0.98_* 0.01 0.00 -#> 60 0.00 0.00 0.00 1.01_* 0.00 0.01 -#> 118 0.01 0.01 0.02 1.01_* 0.00 0.01 -#> 137 -0.10 -0.01 -0.10 0.98_* 0.01 0.00 -#> 143 -0.02 -0.04 -0.05 1.01_* 0.00 0.01 -#> 157 -0.10 -0.05 -0.11 0.99_* 0.01 0.00 -#> 166 0.00 0.00 0.00 1.02_* 0.00 0.02_* -#> 168 0.01 0.02 0.03 1.01_* 0.00 0.01 -#> 176 -0.10 0.17 -0.20_* 0.99 0.02 0.01 -#> 177 0.03 -0.07 0.08 1.01_* 0.00 0.01 -#> 191 0.01 0.04 0.04 1.02_* 0.00 0.02_* -#> 192 0.10 0.18 0.20_* 0.99 0.02 0.01 -#> 201 -0.10 0.07 -0.12 0.99_* 0.01 0.00 -#> 216 0.02 0.05 0.05 1.02_* 0.00 0.01_* -#> 217 0.03 0.08 0.09 1.02_* 0.00 0.01_* -#> 225 -0.11 -0.07 -0.13 0.98_* 0.01 0.00 -#> 237 -0.10 0.02 -0.10 0.99_* 0.01 0.00 -#> 242 -0.02 -0.04 -0.04 1.01_* 0.00 0.01 -#> 287 0.14 -0.23 0.27_* 0.97_* 0.04 0.01 -#> 290 -0.18 -0.35 -0.40_* 0.95_* 0.08 0.01 -#> 295 -0.01 -0.01 -0.01 1.01_* 0.00 0.01 -#> 322 0.00 0.00 0.00 1.01_* 0.00 0.01 -#> 325 -0.10 -0.07 -0.12 0.99_* 0.01 0.00 -#> 351 0.19 -0.04 0.20_* 0.94_* 0.02 0.00 -#> 369 0.01 -0.03 0.03 1.01_* 0.00 0.01 -#> 376 -0.05 -0.13 -0.14 1.02_* 0.01 0.02_* -#> 392 -0.04 0.08 -0.09 1.01_* 0.00 0.01 -#> 393 -0.03 0.06 -0.07 1.01_* 0.00 0.01 -#> 394 -0.01 0.03 -0.03 1.01_* 0.00 0.01 -#> 402 0.10 0.02 0.10 0.99_* 0.01 0.00 -#> 429 0.13 -0.10 0.16 0.98_* 0.01 0.00 -#> 430 -0.11 -0.23 -0.25_* 0.99 0.03 0.01 -#> 438 0.00 -0.01 -0.01 1.01_* 0.00 0.01 -#> 442 -0.01 0.04 -0.04 1.02_* 0.00 0.02_* -#> 443 -0.01 0.02 -0.02 1.02_* 0.00 0.01_* -#> 461 0.02 0.04 0.04 1.01_* 0.00 0.01 -#> 462 0.01 0.03 0.03 1.03_* 0.00 0.02_* -#> 466 0.01 -0.02 0.02 1.02_* 0.00 0.01_* -#> 467 -0.03 0.08 -0.08 1.02_* 0.00 0.01_* -#> 468 0.02 -0.04 0.04 1.01_* 0.00 0.01 -#> 480 0.13 0.05 0.14 0.97_* 0.01 0.00 -#> 488 0.16 0.09 0.18 0.96_* 0.02 0.00 -#> 492 -0.13 0.12 -0.17 0.98_* 0.01 0.00 infl <- as.integer(rownames(zz)) points(plt_out$X[infl], plt_out$Y[infl], pch=3, cex=0.6, col="red") - crossprod(plt_out$Y, plt_out$X)/crossprod(plt_out$X) -#> [,1] -#> [1,] 0.6601805 wheat$localAple <- localAple(as.vector(scale(wheat$yield_detrend, scale=FALSE)), spdep::nb2listw(nbr12, style="W")) mean(wheat$localAple) -#> [1] 0.6601805 hist(wheat$localAple) - opar <- par(no.readonly=TRUE) plot(wheat[,"localAple"], reset=FALSE) text(st_coordinates(st_centroid(st_geometry(wheat)))[infl,], labels=rep("*", length(infl))) - par(opar) -# } +}
@@ -221,7 +167,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/do_ldet.html b/docs/reference/do_ldet.html index 105ff01..7d93dd2 100644 --- a/docs/reference/do_ldet.html +++ b/docs/reference/do_ldet.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -148,9 +148,9 @@

Arguments

default TRUE: truncate Smirnov correction term, see trW

eq7
-

default TRUE

-

use equation 7 in Smirnov and Anselin (2009), if FALSE no unit root correction

-
SE_method
+

default TRUE; use equation 7 in Smirnov and Anselin (2009), if FALSE no unit root correction

+ +
SE_method

default “LU”, alternatively “MC”; underlying lndet method to use for generating SE toolbox emulation grid

nrho
@@ -609,7 +609,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/eigenw.html b/docs/reference/eigenw.html index 9a5aac9..b29e22d 100644 --- a/docs/reference/eigenw.html +++ b/docs/reference/eigenw.html @@ -23,7 +23,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -221,7 +221,7 @@

Examples

rg_GS <- griffith_sone(P=7, Q=7, type="rook") all.equal(rg_eig, rg_GS) #> [1] TRUE -# \dontrun{ +if (FALSE) { run <- FALSE if (require("RSpectra", quietly=TRUE)) run <- TRUE if (run) { @@ -230,22 +230,18 @@

Examples

resn <- eigs(B, k=1, which="SR")$values print(Re(c(resn, res1))) } -#> [1] -3.695518 3.695518 if (run) { print(all.equal(range(Re(rg_eig)), c(resn, res1))) } -#> [1] TRUE if (run) { lw <- spdep::nb2listw(rg, style="W") rg_eig <- eigenw(similar.listw(lw)) print(range(Re(rg_eig))) } -#> [1] -1 1 if (run) { W <- as(lw, "CsparseMatrix") print(Re(c(eigs(W, k=1, which="SR")$values, eigs(W, k=1, which="LR")$values))) -}# } -#> [1] -1 1 +}}
@@ -260,7 +256,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/gstsls-1.png b/docs/reference/gstsls-1.png index c25d20a..2d3b30b 100644 Binary files a/docs/reference/gstsls-1.png and b/docs/reference/gstsls-1.png differ diff --git a/docs/reference/gstsls.html b/docs/reference/gstsls.html index c7e542b..57884b0 100644 --- a/docs/reference/gstsls.html +++ b/docs/reference/gstsls.html @@ -18,7 +18,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -72,7 +72,7 @@

Spatial simultaneous autoregressive SAC model estimation by GMM

gstsls(formula, data = list(), listw, listw2 = NULL, na.action = na.fail, 
-    zero.policy = NULL, pars=NULL, scaleU=FALSE, control = list(), 
+    zero.policy = attr(listw, "zero.policy"), pars=NULL, scaleU=FALSE, control = list(), 
     verbose=NULL, method="nlminb", robust=FALSE, legacy=FALSE, W2X=TRUE) 
 # S3 method for Gmsar
 impacts(obj, ..., n = NULL, tr = NULL, R = NULL,
@@ -327,7 +327,7 @@ 

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/impacts.html b/docs/reference/impacts.html index 27950c6..6a506b2 100644 --- a/docs/reference/impacts.html +++ b/docs/reference/impacts.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -229,12 +229,12 @@

Examples

#> #> Residuals: #> Min 1Q Median 3Q Max -#> -37.4497094 -5.4565567 0.0016388 6.7159553 24.7107975 +#> -37.4497093 -5.4565567 0.0016387 6.7159553 24.7107978 #> #> Type: lag #> Coefficients: (asymptotic standard errors) #> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) 46.851430 7.314754 6.4051 1.503e-10 +#> (Intercept) 46.851431 7.314754 6.4051 1.503e-10 #> INC -1.073533 0.310872 -3.4533 0.0005538 #> HOVAL -0.269997 0.090128 -2.9957 0.0027381 #> @@ -247,7 +247,7 @@

Examples

#> ML residual variance (sigma squared): 99.164, (sigma: 9.9581) #> Number of observations: 49 #> Number of parameters estimated: 5 -#> AIC: 376.34, (AIC for lm: 382.75) +#> AIC: NA (not available for weighted model), (AIC for lm: 382.75) #> LM test for residual autocorrelation #> test value: 0.19184, p-value: 0.66139 #> @@ -280,7 +280,7 @@

Examples

#> ML residual variance (sigma squared): 95.051, (sigma: 9.7494) #> Number of observations: 49 #> Number of parameters estimated: 7 -#> AIC: 378.03, (AIC for lm: 380.2) +#> AIC: NA (not available for weighted model), (AIC for lm: 380.2) #> LM test for residual autocorrelation #> test value: 0.101, p-value: 0.75063 #> @@ -298,10 +298,10 @@

Examples

#> Type: mixed #> Coefficients: (asymptotic standard errors) #> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) 51.951208 12.577338 4.1305 3.619e-05 +#> (Intercept) 51.951213 12.577339 4.1305 3.619e-05 #> INC -1.038812 0.337656 -3.0765 0.002094 #> HOVAL -0.269345 0.090406 -2.9793 0.002889 -#> lag.INC -0.254653 0.544298 -0.4679 0.639888 +#> lag.INC -0.254653 0.544298 -0.4679 0.639887 #> #> Rho: 0.35028, LR test value: 3.4351, p-value: 0.063823 #> Asymptotic standard error: 0.1617 @@ -312,7 +312,7 @@

Examples

#> ML residual variance (sigma squared): 99.846, (sigma: 9.9923) #> Number of observations: 49 #> Number of parameters estimated: 6 -#> AIC: 378.13, (AIC for lm: 379.57) +#> AIC: NA (not available for weighted model), (AIC for lm: 379.57) #> LM test for residual autocorrelation #> test value: 2.5646, p-value: 0.10928 #> @@ -323,12 +323,12 @@

Examples

impacts(lobj, listw=listw) #> Impact measures (lag, exact): #> Direct Indirect Total -#> INC -1.1225155 -0.6783818 -1.8008973 +#> INC -1.1225156 -0.6783818 -1.8008973 #> HOVAL -0.2823163 -0.1706152 -0.4529315 impacts(lobj, tr=trMatc) #> Impact measures (lag, trace): #> Direct Indirect Total -#> INC -1.1225155 -0.6783818 -1.8008973 +#> INC -1.1225156 -0.6783818 -1.8008973 #> HOVAL -0.2823163 -0.1706152 -0.4529315 impacts(lobj, tr=trMC) #> Impact measures (lag, trace): @@ -338,131 +338,131 @@

Examples

impacts(lobj, evalues=ev) #> Impact measures (lag, evalues): #> Direct Indirect Total -#> INC -1.1225155 -0.6783818 -1.8008973 +#> INC -1.1225156 -0.6783818 -1.8008973 #> HOVAL -0.2823163 -0.1706152 -0.4529315 library(coda) lobjIQ5 <- impacts(lobj, tr=trMatc, R=200, Q=5) summary(lobjIQ5, zstats=TRUE, short=TRUE) #> Impact measures (lag, trace): #> Direct Indirect Total -#> INC -1.1225155 -0.6783818 -1.8008973 +#> INC -1.1225156 -0.6783818 -1.8008973 #> HOVAL -0.2823163 -0.1706152 -0.4529315 #> ======================================================== #> Simulation results ( variance matrix): #> ======================================================== #> Simulated standard errors #> Direct Indirect Total -#> INC 0.3366296 0.4409179 0.6472849 -#> HOVAL 0.1027792 0.1224540 0.2005825 +#> INC 0.3298544 0.3834114 0.5945946 +#> HOVAL 0.1014420 0.1261509 0.2033617 #> #> Simulated z-values: #> Direct Indirect Total -#> INC -3.414037 -1.681159 -2.920691 -#> HOVAL -2.801138 -1.584607 -2.402703 +#> INC -3.417467 -1.886887 -3.112575 +#> HOVAL -2.895853 -1.551116 -2.406724 #> #> Simulated p-values: #> Direct Indirect Total -#> INC 0.00064008 0.092732 0.0034926 -#> HOVAL 0.00509228 0.113056 0.0162744 +#> INC 0.00063207 0.059176 0.0018546 +#> HOVAL 0.00378129 0.120874 0.0160963 summary(lobjIQ5, zstats=TRUE, short=TRUE, reportQ=TRUE) #> Impact measures (lag, trace): #> Direct Indirect Total -#> INC -1.1225155 -0.6783818 -1.8008973 +#> INC -1.1225156 -0.6783818 -1.8008973 #> HOVAL -0.2823163 -0.1706152 -0.4529315 #> ================================= #> Impact components #> $direct #> INC HOVAL -#> Q1 -1.073533437 -0.2699971234 +#> Q1 -1.073533466 -0.2699971236 #> Q2 0.000000000 0.0000000000 -#> Q3 -0.038985418 -0.0098049584 -#> Q4 -0.005269655 -0.0013253352 -#> Q5 -0.003276080 -0.0008239446 +#> Q3 -0.038985415 -0.0098049573 +#> Q4 -0.005269654 -0.0013253350 +#> Q5 -0.003276079 -0.0008239444 #> #> $indirect #> INC HOVAL #> Q1 0.00000000 0.000000000 -#> Q2 -0.43358911 -0.109049060 -#> Q3 -0.13613676 -0.034238835 -#> Q4 -0.06546039 -0.016463500 -#> Q5 -0.02529106 -0.006360783 +#> Q2 -0.43358910 -0.109049054 +#> Q3 -0.13613675 -0.034238831 +#> Q4 -0.06546038 -0.016463497 +#> Q5 -0.02529105 -0.006360781 #> #> $total #> INC HOVAL -#> Q1 -1.07353344 -0.269997123 -#> Q2 -0.43358911 -0.109049060 -#> Q3 -0.17512218 -0.044043793 -#> Q4 -0.07073005 -0.017788835 -#> Q5 -0.02856714 -0.007184727 +#> Q1 -1.07353347 -0.269997124 +#> Q2 -0.43358910 -0.109049054 +#> Q3 -0.17512216 -0.044043788 +#> Q4 -0.07073004 -0.017788832 +#> Q5 -0.02856713 -0.007184726 #> #> ======================================================== #> Simulation results ( variance matrix): #> ======================================================== #> Simulated standard errors #> Direct Indirect Total -#> INC 0.3366296 0.4409179 0.6472849 -#> HOVAL 0.1027792 0.1224540 0.2005825 +#> INC 0.3298544 0.3834114 0.5945946 +#> HOVAL 0.1014420 0.1261509 0.2033617 #> #> Simulated z-values: #> Direct Indirect Total -#> INC -3.414037 -1.681159 -2.920691 -#> HOVAL -2.801138 -1.584607 -2.402703 +#> INC -3.417467 -1.886887 -3.112575 +#> HOVAL -2.895853 -1.551116 -2.406724 #> #> Simulated p-values: #> Direct Indirect Total -#> INC 0.00064008 0.092732 0.0034926 -#> HOVAL 0.00509228 0.113056 0.0162744 +#> INC 0.00063207 0.059176 0.0018546 +#> HOVAL 0.00378129 0.120874 0.0160963 #> ======================================================== #> Simulated impact components z-values: #> $Direct -#> INC HOVAL -#> Q1 -3.327848 -2.7936866 -#> Q2 NaN NaN -#> Q3 -1.702009 -1.5031474 -#> Q4 -1.147968 -1.1167765 -#> Q5 -0.820115 -0.8730749 +#> INC HOVAL +#> Q1 -3.3247602 -2.9008692 +#> Q2 NaN NaN +#> Q3 -1.7540115 -1.4638039 +#> Q4 -1.2444388 -1.0830402 +#> Q5 -0.9405222 -0.8474166 #> #> $Indirect -#> INC HOVAL -#> Q1 NaN NaN -#> Q2 -2.733849 -2.1632321 -#> Q3 -1.702009 -1.5031474 -#> Q4 -1.147968 -1.1167765 -#> Q5 -0.820115 -0.8730749 +#> INC HOVAL +#> Q1 NaN NaN +#> Q2 -2.6977076 -2.1475985 +#> Q3 -1.7540115 -1.4638039 +#> Q4 -1.2444388 -1.0830402 +#> Q5 -0.9405222 -0.8474166 #> #> $Total -#> INC HOVAL -#> Q1 -3.327848 -2.7936866 -#> Q2 -2.733849 -2.1632321 -#> Q3 -1.702009 -1.5031474 -#> Q4 -1.147968 -1.1167765 -#> Q5 -0.820115 -0.8730749 +#> INC HOVAL +#> Q1 -3.3247602 -2.9008692 +#> Q2 -2.6977076 -2.1475985 +#> Q3 -1.7540115 -1.4638039 +#> Q4 -1.2444388 -1.0830402 +#> Q5 -0.9405222 -0.8474166 #> #> #> Simulated impact components p-values: #> $Direct -#> INC HOVAL -#> Q1 0.0008752 0.0052111 -#> Q2 NA NA -#> Q3 0.0887538 0.1328010 -#> Q4 0.2509819 0.2640899 -#> Q5 0.4121506 0.3826223 +#> INC HOVAL +#> Q1 0.00088495 0.0037213 +#> Q2 NA NA +#> Q3 0.07942853 0.1432475 +#> Q4 0.21333812 0.2787906 +#> Q5 0.34694975 0.3967630 #> #> $Indirect #> INC HOVAL #> Q1 NA NA -#> Q2 0.0062599 0.030523 -#> Q3 0.0887538 0.132801 -#> Q4 0.2509819 0.264090 -#> Q5 0.4121506 0.382622 +#> Q2 0.0069819 0.031746 +#> Q3 0.0794285 0.143248 +#> Q4 0.2133381 0.278791 +#> Q5 0.3469497 0.396763 #> #> $Total -#> INC HOVAL -#> Q1 0.0008752 0.0052111 -#> Q2 0.0062599 0.0305233 -#> Q3 0.0887538 0.1328010 -#> Q4 0.2509819 0.2640899 -#> Q5 0.4121506 0.3826223 +#> INC HOVAL +#> Q1 0.00088495 0.0037213 +#> Q2 0.00698187 0.0317457 +#> Q3 0.07942853 0.1432475 +#> Q4 0.21333812 0.2787906 +#> Q5 0.34694975 0.3967630 #> impacts(mobj, listw=listw) #> Impact measures (mixed, exact): @@ -489,13 +489,9 @@

Examples

#> Direct Indirect Total #> INC -1.0968247 -0.8939687 -1.9907934 #> HOVAL -0.2781941 -0.1363596 -0.4145537 -# \dontrun{ +if (FALSE) { try(impacts(mobj, evalues=ev), silent=TRUE) -#> Impact measures (mixed, evalues): -#> Direct Indirect Total -#> INC -1.0418080 -1.4804246 -2.52223255 -#> HOVAL -0.2836325 0.2302055 -0.05342697 -# } +} summary(impacts(mobj, tr=trMatc, R=200), short=TRUE, zstats=TRUE) #> Impact measures (mixed, trace): #> Direct Indirect Total @@ -528,21 +524,21 @@

Examples

#> ======================================================== #> Simulated standard errors #> Direct Indirect Total -#> INC 0.3782124 0.6845199 0.7659469 -#> HOVAL 0.1031391 0.1954851 0.2548427 +#> INC 0.3752297 0.6525338 0.7183806 +#> HOVAL 0.1078220 0.1277117 0.1990840 #> #> Simulated z-values: -#> Direct Indirect Total -#> INC -2.898476 -1.2616836 -2.558777 -#> HOVAL -2.880290 -0.8992903 -1.855531 +#> Direct Indirect Total +#> INC -2.902700 -1.247249 -2.649084 +#> HOVAL -2.637881 -1.168002 -2.177921 #> #> Simulated p-values: #> Direct Indirect Total -#> INC 0.0037498 0.20706 0.010504 -#> HOVAL 0.0039731 0.36850 0.063520 +#> INC 0.0036996 0.21231 0.008071 +#> HOVAL 0.0083426 0.24281 0.029412 xobj <- lmSLX(CRIME ~ INC + HOVAL, columbus, listw) summary(impacts(xobj)) -#> Impact measures (SlX, estimable, n-k): +#> Impact measures (SlX, glht, n-k): #> Direct Indirect Total #> INC -1.1081273 -1.3834468 -2.49157410 #> HOVAL -0.2949095 0.2261538 -0.06875574 @@ -564,7 +560,7 @@

Examples

#> eobj <- errorsarlm(CRIME ~ INC + HOVAL, columbus, listw, etype="emixed") summary(impacts(eobj), adjust_k=TRUE) -#> Impact measures (SDEM, estimable, n): +#> Impact measures (SDEM, glht, n): #> Direct Indirect Total #> INC -1.0695301 -1.1967736 -2.2663036 #> HOVAL -0.2803441 0.1467585 -0.1335856 @@ -576,143 +572,29 @@

Examples

#> ======================================================== #> Z-values: #> Direct Indirect Total -#> INC -3.293714 -2.1034125 -3.6497667 +#> INC -3.293714 -2.1034124 -3.6497665 #> HOVAL -3.053548 0.7306064 -0.5749284 #> #> p-values: #> Direct Indirect Total #> INC 0.00098873 0.03543 0.00026248 -#> HOVAL 0.00226152 0.46502 0.56533972 +#> HOVAL 0.00226152 0.46502 0.56533971 #> -# \dontrun{ +if (FALSE) { mobj1 <- lagsarlm(CRIME ~ INC + HOVAL, columbus, listw, type="mixed", method="Matrix", control=list(fdHess=TRUE)) summary(mobj1) -#> -#> Call:lagsarlm(formula = CRIME ~ INC + HOVAL, data = columbus, listw = listw, -#> type = "mixed", method = "Matrix", control = list(fdHess = TRUE)) -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -37.15904 -6.62594 -0.39823 6.57561 23.62757 -#> -#> Type: mixed -#> Coefficients: (asymptotic standard errors) -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) 45.592896 14.240041 3.2017 0.0013660 -#> INC -0.939088 0.343069 -2.7373 0.0061942 -#> HOVAL -0.299605 0.090393 -3.3145 0.0009182 -#> lag.INC -0.618375 0.607708 -1.0176 0.3088903 -#> lag.HOVAL 0.266615 0.181524 1.4688 0.1418998 -#> -#> Rho: 0.38251, LR test value: 4.1648, p-value: 0.041272 -#> Asymptotic standard error: 0.17375 -#> z-value: 2.2015, p-value: 0.027702 -#> Wald statistic: 4.8465, p-value: 0.027702 -#> -#> Log likelihood: -182.0161 for mixed model -#> ML residual variance (sigma squared): 95.051, (sigma: 9.7494) -#> Number of observations: 49 -#> Number of parameters estimated: 7 -#> AIC: 378.03, (AIC for lm: 380.2) -#> LM test for residual autocorrelation -#> test value: 0.101, p-value: 0.75063 -#> set.seed(1) summary(impacts(mobj1, tr=trMatc, R=1000), zstats=TRUE, short=TRUE) -#> Impact measures (mixed, trace): -#> Direct Indirect Total -#> INC -1.0418080 -1.4804246 -2.52223255 -#> HOVAL -0.2836325 0.2302055 -0.05342697 -#> ======================================================== -#> Simulation results ( variance matrix): -#> ======================================================== -#> Simulated standard errors -#> Direct Indirect Total -#> INC 0.34686331 0.8324743 0.8959688 -#> HOVAL 0.09085583 0.3131242 0.3483785 -#> -#> Simulated z-values: -#> Direct Indirect Total -#> INC -3.023902 -1.8284275 -2.8695190 -#> HOVAL -3.120537 0.7910739 -0.1028036 -#> -#> Simulated p-values: -#> Direct Indirect Total -#> INC 0.0024954 0.067485 0.004111 -#> HOVAL 0.0018052 0.428901 0.918119 summary(impacts(mobj, tr=trMatc, R=1000), zstats=TRUE, short=TRUE) -#> Impact measures (mixed, trace): -#> Direct Indirect Total -#> INC -1.0418080 -1.4804246 -2.52223255 -#> HOVAL -0.2836325 0.2302055 -0.05342697 -#> ======================================================== -#> Simulation results ( variance matrix): -#> ======================================================== -#> Simulated standard errors -#> Direct Indirect Total -#> INC 0.3123750 0.8291512 0.8821167 -#> HOVAL 0.0922758 0.2961092 0.3267773 -#> -#> Simulated z-values: -#> Direct Indirect Total -#> INC -3.330304 -1.8060414 -2.8769263 -#> HOVAL -3.099811 0.8140556 -0.1376722 -#> -#> Simulated p-values: -#> Direct Indirect Total -#> INC 0.00086751 0.070912 0.0040157 -#> HOVAL 0.00193644 0.415613 0.8904995 mobj2 <- lagsarlm(CRIME ~ INC + HOVAL, columbus, listw, type="mixed", method="Matrix", control=list(fdHess=TRUE, optimHess=TRUE)) summary(impacts(mobj2, tr=trMatc, R=1000), zstats=TRUE, short=TRUE) -#> Impact measures (mixed, trace): -#> Direct Indirect Total -#> INC -1.0418080 -1.4804246 -2.52223255 -#> HOVAL -0.2836325 0.2302055 -0.05342697 -#> ======================================================== -#> Simulation results ( variance matrix): -#> ======================================================== -#> Simulated standard errors -#> Direct Indirect Total -#> INC 0.32853332 0.8044059 0.8615603 -#> HOVAL 0.09291975 0.3169361 0.3571304 -#> -#> Simulated z-values: -#> Direct Indirect Total -#> INC -3.231204 -1.8690203 -2.9771674 -#> HOVAL -3.026494 0.7323897 -0.1374858 -#> -#> Simulated p-values: -#> Direct Indirect Total -#> INC 0.0012327 0.06162 0.0029093 -#> HOVAL 0.0024741 0.46393 0.8906468 mobj3 <- lagsarlm(CRIME ~ INC + HOVAL, columbus, listw, type="mixed", method="spam", control=list(fdHess=TRUE)) summary(impacts(mobj3, tr=trMatc, R=1000), zstats=TRUE, short=TRUE) -#> Impact measures (mixed, trace): -#> Direct Indirect Total -#> INC -1.0418080 -1.4804246 -2.52223255 -#> HOVAL -0.2836325 0.2302055 -0.05342697 -#> ======================================================== -#> Simulation results ( variance matrix): -#> ======================================================== -#> Simulated standard errors -#> Direct Indirect Total -#> INC 0.32866009 0.8664620 0.9215792 -#> HOVAL 0.09837849 0.3110899 0.3492674 -#> -#> Simulated z-values: -#> Direct Indirect Total -#> INC -3.190433 -1.7325351 -2.766712 -#> HOVAL -2.890221 0.7694814 -0.128720 -#> -#> Simulated p-values: -#> Direct Indirect Total -#> INC 0.0014206 0.083178 0.0056625 -#> HOVAL 0.0038497 0.441608 0.8975792 -# } -# \dontrun{ +} +if (FALSE) { data(boston, package="spData") Wb <- as(spdep::nb2listw(boston.soi), "CsparseMatrix") trMatb <- trW(Wb, type="mult") @@ -721,126 +603,7 @@

Examples

data=boston.c, spdep::nb2listw(boston.soi), type="mixed", method="Matrix", control=list(fdHess=TRUE), trs=trMatb) summary(gp2mMi) -#> -#> Call:lagsarlm(formula = log(CMEDV) ~ CRIM + ZN + INDUS + CHAS + I(NOX^2) + -#> I(RM^2) + AGE + log(DIS) + log(RAD) + TAX + PTRATIO + B + -#> log(LSTAT), data = boston.c, listw = spdep::nb2listw(boston.soi), -#> type = "mixed", method = "Matrix", trs = trMatb, control = list(fdHess = TRUE)) -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -0.6316833 -0.0629790 -0.0090776 0.0682421 0.6991072 -#> -#> Type: mixed -#> Coefficients: (asymptotic standard errors) -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) 1.89816218 0.24400182 7.7793 7.327e-15 -#> CRIM -0.00571021 0.00093857 -6.0839 1.173e-09 -#> ZN 0.00069091 0.00051874 1.3319 0.1828931 -#> INDUS -0.00111343 0.00307380 -0.3622 0.7171778 -#> CHAS1 -0.04163225 0.02738839 -1.5201 0.1284937 -#> I(NOX^2) -0.01034950 0.19358633 -0.0535 0.9573639 -#> I(RM^2) 0.00794979 0.00102109 7.7856 6.883e-15 -#> AGE -0.00128789 0.00048929 -2.6322 0.0084838 -#> log(DIS) -0.12404108 0.09510145 -1.3043 0.1921304 -#> log(RAD) 0.05863502 0.02257529 2.5973 0.0093957 -#> TAX -0.00049084 0.00012146 -4.0412 5.317e-05 -#> PTRATIO -0.01319853 0.00595331 -2.2170 0.0266227 -#> B 0.00056383 0.00011084 5.0867 3.643e-07 -#> log(LSTAT) -0.24724454 0.02265149 -10.9152 < 2.2e-16 -#> lag.CRIM -0.00464215 0.00173900 -2.6694 0.0075978 -#> lag.ZN -0.00037937 0.00070703 -0.5366 0.5915659 -#> lag.INDUS 0.00025064 0.00385911 0.0649 0.9482165 -#> lag.CHAS1 0.12518252 0.04083949 3.0652 0.0021750 -#> lag.I(NOX^2) -0.38640401 0.22253428 -1.7364 0.0824967 -#> lag.I(RM^2) -0.00451252 0.00148919 -3.0302 0.0024440 -#> lag.AGE 0.00149678 0.00068470 2.1860 0.0288128 -#> lag.log(DIS) -0.00453785 0.10056961 -0.0451 0.9640105 -#> lag.log(RAD) -0.00940702 0.03127787 -0.3008 0.7636001 -#> lag.TAX 0.00041083 0.00017859 2.3004 0.0214237 -#> lag.PTRATIO 0.00060355 0.00789994 0.0764 0.9391011 -#> lag.B -0.00050781 0.00014107 -3.5996 0.0003187 -#> lag.log(LSTAT) 0.09846781 0.03574182 2.7550 0.0058697 -#> -#> Rho: 0.59578, LR test value: 181.68, p-value: < 2.22e-16 -#> Asymptotic standard error: 0.037474 -#> z-value: 15.899, p-value: < 2.22e-16 -#> Wald statistic: 252.76, p-value: < 2.22e-16 -#> -#> Log likelihood: 300.6131 for mixed model -#> ML residual variance (sigma squared): 0.016011, (sigma: 0.12654) -#> Number of observations: 506 -#> Number of parameters estimated: 29 -#> AIC: -543.23, (AIC for lm: -363.55) -#> LM test for residual autocorrelation -#> test value: 29.772, p-value: 4.8604e-08 -#> summary(impacts(gp2mMi, tr=trMatb, R=1000), zstats=TRUE, short=TRUE) -#> Impact measures (mixed, trace): -#> Direct Indirect Total -#> CRIM -0.0074555753 -1.815485e-02 -0.0256104225 -#> ZN 0.0006979073 7.279849e-05 0.0007707058 -#> INDUS -0.0012029822 -9.314672e-04 -0.0021344494 -#> CHAS1 -0.0198526436 2.265454e-01 0.2066927455 -#> I(NOX^2) -0.0955268264 -8.859909e-01 -0.9815177559 -#> I(RM^2) 0.0079983430 5.050177e-04 0.0085033608 -#> AGE -0.0011296134 1.646365e-03 0.0005167515 -#> log(DIS) -0.1410601687 -1.770278e-01 -0.3180879407 -#> log(RAD) 0.0641735548 5.761026e-02 0.1217838138 -#> TAX -0.0004651543 2.672120e-04 -0.0001979424 -#> PTRATIO -0.0147737151 -1.638465e-02 -0.0311583673 -#> B 0.0005265343 -3.879424e-04 0.0001385920 -#> log(LSTAT) -0.2578403213 -1.102144e-01 -0.3680547068 -#> ======================================================== -#> Simulation results ( variance matrix): -#> ======================================================== -#> Simulated standard errors -#> Direct Indirect Total -#> CRIM 0.0010076798 0.0036288635 0.0040404924 -#> ZN 0.0004892696 0.0012374985 0.0012596482 -#> INDUS 0.0028820758 0.0060784278 0.0057782835 -#> CHAS1 0.0271174438 0.0816949094 0.0902306757 -#> I(NOX^2) 0.1798525308 0.2954129372 0.2426994803 -#> I(RM^2) 0.0011004204 0.0031441374 0.0036256801 -#> AGE 0.0004759027 0.0012824325 0.0013506324 -#> log(DIS) 0.0884514493 0.1106832532 0.0757292416 -#> log(RAD) 0.0197638019 0.0513249132 0.0502885291 -#> TAX 0.0001125321 0.0003293654 0.0003385003 -#> PTRATIO 0.0054150585 0.0127889718 0.0122254626 -#> B 0.0001047613 0.0002376555 0.0002352788 -#> log(LSTAT) 0.0224736606 0.0610705732 0.0660452868 -#> -#> Simulated z-values: -#> Direct Indirect Total -#> CRIM -7.4241338 -5.0475149 -6.3848388 -#> ZN 1.4320070 0.1005269 0.6549761 -#> INDUS -0.4184563 -0.1088975 -0.3232704 -#> CHAS1 -0.7260662 2.7907466 2.3085356 -#> I(NOX^2) -0.5230875 -3.0572802 -4.1089447 -#> I(RM^2) 7.3364331 0.1789518 2.3818456 -#> AGE -2.4211451 1.2544530 0.3380060 -#> log(DIS) -1.5778892 -1.6651491 -4.2766929 -#> log(RAD) 3.2376717 1.1761160 2.4727856 -#> TAX -4.1072661 0.7673289 -0.6188112 -#> PTRATIO -2.7323833 -1.2913715 -2.5611570 -#> B 5.0195551 -1.6302856 0.5882763 -#> log(LSTAT) -11.4429268 -1.7773204 -5.5372071 -#> -#> Simulated p-values: -#> Direct Indirect Total -#> CRIM 1.1346e-13 4.4759e-07 1.7158e-10 -#> ZN 0.1521418 0.9199260 0.512483 -#> INDUS 0.6756135 0.9132838 0.746490 -#> CHAS1 0.4677982 0.0052587 0.020969 -#> I(NOX^2) 0.6009133 0.0022336 3.9747e-05 -#> I(RM^2) 2.1938e-13 0.8579755 0.017226 -#> AGE 0.0154717 0.2096774 0.735359 -#> log(DIS) 0.1145911 0.0958830 1.8969e-05 -#> log(RAD) 0.0012051 0.2395485 0.013406 -#> TAX 4.0037e-05 0.4428860 0.536041 -#> PTRATIO 0.0062878 0.1965749 0.010432 -#> B 5.1791e-07 0.1030411 0.556347 -#> log(LSTAT) < 2.22e-16 0.0755155 3.0733e-08 #data(house, package="spData") #lw <- spdep::nb2listw(LO_nb) #form <- formula(log(price) ~ age + I(age^2) + I(age^3) + log(lotsize) + @@ -858,7 +621,7 @@

Examples

#summary(mobj) #moobj <- impacts(mobj, tr=trMat, R=1000) #summary(moobj, zstats=TRUE, short=TRUE) -# } +}
@@ -873,7 +636,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/index.html b/docs/reference/index.html index a3d447d..4e93c3e 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -184,7 +184,7 @@

All functions
-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/invIrM-1.png b/docs/reference/invIrM-1.png index e88ae6b..f2caba2 100644 Binary files a/docs/reference/invIrM-1.png and b/docs/reference/invIrM-1.png differ diff --git a/docs/reference/invIrM.html b/docs/reference/invIrM.html index 80d0a2e..79aba82 100644 --- a/docs/reference/invIrM.html +++ b/docs/reference/invIrM.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -174,21 +174,13 @@

Examples

col=c("black", "brown", "green", "orange", "pink", "red"), lty=1, bty="n") } -# \dontrun{ +if (FALSE) { x <- matrix(rnorm(length(nb7rt)), ncol=1) system.time(e <- invIrM(nb7rt, rho=0.9, method="chol", feasible=TRUE) %*% x) -#> user system elapsed -#> 0.005 0.000 0.004 system.time(e <- invIrM(nb7rt, rho=0.9, method="chol", feasible=NULL) %*% x) -#> user system elapsed -#> 0.005 0.000 0.005 system.time(e <- invIrM(nb7rt, rho=0.9, method="solve", feasible=TRUE) %*% x) -#> user system elapsed -#> 0.002 0.000 0.002 system.time(e <- invIrM(nb7rt, rho=0.9, method="solve", feasible=NULL) %*% x) -#> user system elapsed -#> 0.003 0.000 0.002 -# } +}
@@ -203,7 +195,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/lagmess.html b/docs/reference/lagmess.html index 4e86d42..7a721cc 100644 --- a/docs/reference/lagmess.html +++ b/docs/reference/lagmess.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -86,7 +86,7 @@

Arguments

is called.

listw
-

a listw object created for example by nb2listw

+

a listw object created for example by spdep::nb2listw()

zero.policy

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without @@ -118,9 +118,9 @@

Arguments

Details

The underlying spatial lag model:

$$y = \rho W y + X \beta + \varepsilon$$

-

where \(\rho\) is the spatial parameter may be fitted by maximum likelihood. In that case, the log likelihood function includes the logartithm of cumbersome Jacobian term \(|I - \rho W|\). If we rewrite the model as:

+

where \(\rho\) is the spatial parameter may be fitted by maximum likelihood. In that case, the log likelihood function includes the logarithm of cumbersome Jacobian term \(|I - \rho W|\). If we rewrite the model as:

$$S y = X \beta + \varepsilon$$

-

we see that in the ML case \(S y = (I - \rho W) y\). If W is row-stochastic, S may be expressed as a linear combination of row-stochastic matrices. By pre-computing the matrix \([y Wy, W^2y, ..., W^{q-1}y]\), the term \(S y (\alpha)\) can readily be found by numerical optimization using the matrix exponential approach. \(\alpha\) and \(\rho\) are related as \(\rho = 1 - \exp{\alpha}\), conditional on the number of matrix power terms taken q.

+

we see that in the ML case \(S y = (I - \rho W) y\). If W is row-stochastic, S may be expressed as a linear combination of row-stochastic matrices. By pre-computing the matrix \([y, Wy, W^2y, ..., W^{q-1}y]\), the term \(S y (\alpha)\) can readily be found by numerical optimization using the matrix exponential approach. \(\alpha\) and \(\rho\) are related as \(\rho = 1 - \exp{\alpha}\), conditional on the number of matrix power terms taken q.

Value

@@ -244,7 +244,7 @@

Examples

#> system.time(obj2 <- lagmess(log(PRICE) ~ PATIO + log(AGE) + log(SQFT), data=baltimore, listw=lw)) #> user system elapsed -#> 0.060 0.000 0.061 +#> 0.034 0.000 0.035 (x <- summary(obj2)) #> Matrix exponential spatial lag model: #> @@ -274,15 +274,22 @@

Examples

#> coef(x) #> Estimate Std. Error t value Pr(>|t|) -#> (Intercept) 1.5463761 0.21451319 7.208770 1.038762e-11 +#> (Intercept) 1.5463761 0.21451319 7.208769 1.038762e-11 #> PATIO 0.2582874 0.08689079 2.972552 3.303312e-03 #> log(AGE) -0.1481738 0.03525174 -4.203305 3.912250e-05 #> log(SQFT) 0.3009659 0.07159771 4.203569 3.908038e-05 -system.time(obj2a <- lagmess(log(PRICE) ~ PATIO + log(AGE) + log(SQFT), data=baltimore, listw=lw, - use_expm=TRUE)) -#> user system elapsed -#> 0.684 0.001 0.688 +has_expm <- require("expm", quietly=TRUE) +#> +#> Attaching package: ‘expm’ +#> The following object is masked from ‘package:Matrix’: +#> +#> expm +if (has_expm) { +system.time( +obj2a <- lagmess(log(PRICE) ~ PATIO + log(AGE) + log(SQFT), data=baltimore, listw=lw, use_expm=TRUE) +) summary(obj2a) +} #> Matrix exponential spatial lag model: #> (calculated with expm) #> @@ -337,7 +344,7 @@

Examples

#> ML residual variance (sigma squared): 0.1589, (sigma: 0.39862) #> Number of observations: 211 #> Number of parameters estimated: 6 -#> AIC: 232.85, (AIC for lm: 283.51) +#> AIC: NA (not available for weighted model), (AIC for lm: 283.51) #> LM test for residual autocorrelation #> test value: 8.7942, p-value: 0.0030219 #> @@ -364,7 +371,7 @@

Examples

#> CRIM -7.1045e-03 9.6236e-04 -7.3824 1.554e-13 #> ZN 3.7985e-04 3.8510e-04 0.9864 0.3239507 #> INDUS 1.2572e-03 1.7986e-03 0.6990 0.4845472 -#> CHAS1 7.3677e-03 2.5416e-02 0.2899 0.7719059 +#> CHAS1 7.3677e-03 2.5416e-02 0.2899 0.7719057 #> I(NOX^2) -2.6892e-01 8.8026e-02 -3.0550 0.0022508 #> I(RM^2) 6.7243e-03 1.0039e-03 6.6985 2.106e-11 #> AGE -2.7682e-04 4.0062e-04 -0.6910 0.4895829 @@ -384,7 +391,7 @@

Examples

#> ML residual variance (sigma squared): 0.019276, (sigma: 0.13884) #> Number of observations: 506 #> Number of parameters estimated: 16 -#> AIC: -496.02, (AIC for lm: -283.96) +#> AIC: NA (not available for weighted model), (AIC for lm: -283.96) #> LM test for residual autocorrelation #> test value: 10.74, p-value: 0.0010486 #> @@ -444,7 +451,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/lextrB.html b/docs/reference/lextrB.html index 17635f4..66dd4ea 100644 --- a/docs/reference/lextrB.html +++ b/docs/reference/lextrB.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -172,25 +172,22 @@

Examples

eigs(B, k=1, which="LR")$values } #> [1] 1 -# \dontrun{ +if (FALSE) { ab.listw <- spdep::nb2listw(boston.soi, style="S") er <- range(eigenw(similar.listw(ab.listw))) er -#> [1] -0.723495 1.110373 res_1 <- lextrS(ab.listw) c(res_1) -#> lambda_n lambda_1 -#> -0.7230376 1.1103694 -# } +} if (run) { B <- as(similar.listw(ab.listw), "CsparseMatrix") eigs(B, k=1, which="SR")$values } -#> [1] -0.723495 +#> [1] -0.9708644 if (run) { eigs(B, k=1, which="LR")$values } -#> [1] 1.110373 +#> [1] 1 @@ -205,7 +202,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/predict.sarlm.html b/docs/reference/predict.sarlm.html index 9b4fe07..5769d17 100644 --- a/docs/reference/predict.sarlm.html +++ b/docs/reference/predict.sarlm.html @@ -21,7 +21,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -227,108 +227,108 @@

Examples

type="mixed") print(p1 <- predict(COL.mix.eig)) #> This method assumes the response is known - see manual page -#> fit trend signal -#> 1001 26.044311 14.8543508 11.189960 -#> 1002 44.034234 29.2632112 14.771023 -#> 1003 43.511934 25.8193818 17.692553 -#> 1004 37.656561 16.4555583 21.201002 -#> 1005 10.902976 0.3664066 10.536570 -#> 1006 36.829798 24.2905246 12.539274 -#> 1007 44.290467 27.0386615 17.251806 -#> 1008 38.853571 21.5342393 17.319331 -#> 1009 50.870854 29.5092783 21.361576 -#> 1010 16.401300 5.6029104 10.798389 -#> 1011 36.354390 28.6415353 7.712855 -#> 1012 20.452836 12.4607277 7.992108 -#> 1013 20.324088 14.4173433 5.906745 -#> 1014 19.243496 10.2606419 8.982854 -#> 1015 19.747775 12.2556861 7.492089 -#> 1016 6.962527 -2.0137491 8.976276 -#> 1017 7.452143 -6.3808928 13.833036 -#> 1018 28.481587 14.2125594 14.269028 -#> 1019 43.351392 28.0442064 15.307186 -#> 1020 50.359682 30.6608153 19.698867 -#> 1021 38.905226 24.7490977 14.156128 -#> 1022 44.724478 28.8314299 15.893048 -#> 1023 37.888974 23.7778863 14.111087 -#> 1024 45.527017 26.9163190 18.610698 -#> 1025 32.429571 17.1892401 15.240331 -#> 1026 26.490842 14.8893980 11.601444 -#> 1027 35.629158 23.4577209 12.171437 -#> 1028 35.574326 21.9001006 13.674226 -#> 1029 38.598639 23.1818442 15.416795 -#> 1030 36.602053 14.8614072 21.740646 -#> 1031 50.320031 30.1013982 20.218633 -#> 1032 53.698863 31.2094168 22.489447 -#> 1033 49.364208 26.5151201 22.849088 -#> 1034 46.262357 25.5538226 20.708534 -#> 1035 39.177121 15.7689329 23.408188 -#> 1036 54.984344 32.6590841 22.325260 -#> 1037 51.611458 33.1290203 18.482438 -#> 1038 51.998831 30.7428313 21.256000 -#> 1039 43.651605 27.4107880 16.240817 -#> 1040 44.196841 25.9409252 18.255916 -#> 1041 49.310592 29.5106497 19.799943 -#> 1042 37.995310 15.7039024 22.291408 -#> 1043 46.908709 28.2687603 18.639948 -#> 1044 28.976789 19.5389223 9.437867 -#> 1045 25.343793 17.1838200 8.159973 -#> 1046 24.006252 16.0103703 7.995882 -#> 1047 25.034907 18.4616473 6.573260 -#> 1048 10.478529 3.3573578 7.121171 -#> 1049 13.495623 5.3356502 8.159973 +#> fit trend signal +#> 1001 26.044310 14.854350 11.189960 +#> 1002 44.034234 29.263210 14.771023 +#> 1003 43.511934 25.819381 17.692554 +#> 1004 37.656561 16.455557 21.201004 +#> 1005 10.902976 0.366406 10.536570 +#> 1006 36.829798 24.290524 12.539274 +#> 1007 44.290467 27.038660 17.251807 +#> 1008 38.853571 21.534238 17.319332 +#> 1009 50.870854 29.509277 21.361577 +#> 1010 16.401300 5.602910 10.798390 +#> 1011 36.354390 28.641535 7.712855 +#> 1012 20.452836 12.460727 7.992109 +#> 1013 20.324088 14.417343 5.906745 +#> 1014 19.243496 10.260642 8.982854 +#> 1015 19.747775 12.255686 7.492089 +#> 1016 6.962527 -2.013749 8.976277 +#> 1017 7.452143 -6.380893 13.833037 +#> 1018 28.481587 14.212559 14.269028 +#> 1019 43.351392 28.044206 15.307187 +#> 1020 50.359682 30.660814 19.698868 +#> 1021 38.905226 24.749097 14.156129 +#> 1022 44.724478 28.831429 15.893049 +#> 1023 37.888974 23.777886 14.111088 +#> 1024 45.527017 26.916318 18.610699 +#> 1025 32.429571 17.189239 15.240332 +#> 1026 26.490842 14.889397 11.601445 +#> 1027 35.629157 23.457720 12.171437 +#> 1028 35.574326 21.900100 13.674226 +#> 1029 38.598639 23.181843 15.416796 +#> 1030 36.602053 14.861406 21.740647 +#> 1031 50.320031 30.101397 20.218634 +#> 1032 53.698863 31.209416 22.489448 +#> 1033 49.364208 26.515119 22.849089 +#> 1034 46.262357 25.553822 20.708535 +#> 1035 39.177121 15.768932 23.408190 +#> 1036 54.984344 32.659083 22.325261 +#> 1037 51.611458 33.129019 18.482439 +#> 1038 51.998831 30.742830 21.256001 +#> 1039 43.651605 27.410787 16.240818 +#> 1040 44.196841 25.940924 18.255917 +#> 1041 49.310593 29.510649 19.799944 +#> 1042 37.995310 15.703901 22.291409 +#> 1043 46.908709 28.268759 18.639949 +#> 1044 28.976789 19.538922 9.437868 +#> 1045 25.343793 17.183819 8.159973 +#> 1046 24.006252 16.010370 7.995883 +#> 1047 25.034907 18.461647 6.573260 +#> 1048 10.478529 3.357357 7.121172 +#> 1049 13.495623 5.335650 8.159973 print(p2 <- predict(COL.mix.eig, newdata=COL.OLD, listw=lw, pred.type = "TS", legacy.mixed = TRUE)) -#> fit trend signal -#> 1001 29.038788 14.8543508 14.184437 -#> 1002 46.227075 29.2632112 16.963864 -#> 1003 45.640479 25.8193818 19.821097 -#> 1004 36.643520 16.4555583 20.187962 -#> 1005 14.819940 0.3664066 14.453533 -#> 1006 38.764777 24.2905246 14.474252 -#> 1007 45.715716 27.0386615 18.677055 -#> 1008 37.514611 21.5342393 15.980372 -#> 1009 49.324228 29.5092783 19.814950 -#> 1010 17.510607 5.6029104 11.907696 -#> 1011 34.973608 28.6415353 6.332072 -#> 1012 21.079100 12.4607277 8.618372 -#> 1013 19.704134 14.4173433 5.286791 -#> 1014 16.365521 10.2606419 6.104879 -#> 1015 17.063856 12.2556861 4.808170 -#> 1016 6.190282 -2.0137491 8.204031 -#> 1017 5.967260 -6.3808928 12.348153 -#> 1018 29.250462 14.2125594 15.037902 -#> 1019 41.530036 28.0442064 13.485830 -#> 1020 49.344770 30.6608153 18.683954 -#> 1021 39.508818 24.7490977 14.759720 -#> 1022 42.772692 28.8314299 13.941262 -#> 1023 37.114901 23.7778863 13.337015 -#> 1024 43.622499 26.9163190 16.706180 -#> 1025 33.247197 17.1892401 16.057957 -#> 1026 30.301331 14.8893980 15.411933 -#> 1027 38.316063 23.4577209 14.858342 -#> 1028 36.886068 21.9001006 14.985967 -#> 1029 38.970564 23.1818442 15.788720 -#> 1030 33.014615 14.8614072 18.153208 -#> 1031 48.209875 30.1013982 18.108477 -#> 1032 50.808064 31.2094168 19.598647 -#> 1033 44.555996 26.5151201 18.040876 -#> 1034 43.232773 25.5538226 17.678951 -#> 1035 35.009061 15.7689329 19.240128 -#> 1036 52.113364 32.6590841 19.454280 -#> 1037 52.189015 33.1290203 19.059995 -#> 1038 51.631805 30.7428313 20.888973 -#> 1039 46.543565 27.4107880 19.132776 -#> 1040 45.036095 25.9409252 19.095170 -#> 1041 45.907835 29.5106497 16.397185 -#> 1042 35.337110 15.7039024 19.633208 -#> 1043 43.948398 28.2687603 15.679638 -#> 1044 32.091257 19.5389223 12.552334 -#> 1045 29.647005 17.1838200 12.463185 -#> 1046 26.375304 16.0103703 10.364934 -#> 1047 27.235807 18.4616473 8.774160 -#> 1048 14.785518 3.3573578 11.428160 -#> 1049 17.798835 5.3356502 12.463185 +#> fit trend signal +#> 1001 29.038788 14.854350 14.184438 +#> 1002 46.227075 29.263210 16.963865 +#> 1003 45.640479 25.819381 19.821099 +#> 1004 36.643520 16.455557 20.187963 +#> 1005 14.819940 0.366406 14.453534 +#> 1006 38.764777 24.290524 14.474253 +#> 1007 45.715716 27.038660 18.677056 +#> 1008 37.514611 21.534238 15.980372 +#> 1009 49.324228 29.509277 19.814951 +#> 1010 17.510606 5.602910 11.907697 +#> 1011 34.973607 28.641535 6.332073 +#> 1012 21.079100 12.460727 8.618373 +#> 1013 19.704134 14.417343 5.286791 +#> 1014 16.365521 10.260642 6.104879 +#> 1015 17.063856 12.255686 4.808170 +#> 1016 6.190282 -2.013749 8.204032 +#> 1017 5.967260 -6.380893 12.348154 +#> 1018 29.250462 14.212559 15.037903 +#> 1019 41.530036 28.044206 13.485830 +#> 1020 49.344769 30.660814 18.683955 +#> 1021 39.508818 24.749097 14.759721 +#> 1022 42.772692 28.831429 13.941263 +#> 1023 37.114901 23.777886 13.337016 +#> 1024 43.622499 26.916318 16.706181 +#> 1025 33.247197 17.189239 16.057958 +#> 1026 30.301331 14.889397 15.411934 +#> 1027 38.316063 23.457720 14.858343 +#> 1028 36.886068 21.900100 14.985968 +#> 1029 38.970564 23.181843 15.788721 +#> 1030 33.014615 14.861406 18.153209 +#> 1031 48.209875 30.101397 18.108478 +#> 1032 50.808064 31.209416 19.598648 +#> 1033 44.555996 26.515119 18.040877 +#> 1034 43.232773 25.553822 17.678952 +#> 1035 35.009061 15.768932 19.240129 +#> 1036 52.113364 32.659083 19.454281 +#> 1037 52.189015 33.129019 19.059996 +#> 1038 51.631805 30.742830 20.888974 +#> 1039 46.543564 27.410787 19.132778 +#> 1040 45.036095 25.940924 19.095171 +#> 1041 45.907835 29.510649 16.397186 +#> 1042 35.337110 15.703901 19.633209 +#> 1043 43.948398 28.268759 15.679639 +#> 1044 32.091257 19.538922 12.552335 +#> 1045 29.647005 17.183819 12.463186 +#> 1046 26.375304 16.010370 10.364935 +#> 1047 27.235807 18.461647 8.774160 +#> 1048 14.785518 3.357357 11.428161 +#> 1049 17.798836 5.335650 12.463186 AIC(COL.mix.eig) #> [1] 376.787 sqrt(deviance(COL.mix.eig)/length(COL.nb)) @@ -377,15 +377,15 @@

Examples

p3 <- predict(COL.mix.eig, newdata=COL.OLD, listw=lw, pred.type = "TS", legacy=FALSE, legacy.mixed = TRUE) -all.equal(p2, p3, check.attributes=FALSE) +all.equal(p2, p3, check.attributes=FALSE) #> [1] TRUE p4 <- predict(COL.mix.eig, newdata=COL.OLD, listw=lw, pred.type = "TS", legacy=FALSE, power=TRUE, legacy.mixed = TRUE) -all.equal(p2, p4, check.attributes=FALSE) +all.equal(p2, p4, check.attributes=FALSE) #> [1] TRUE p5 <- predict(COL.mix.eig, newdata=COL.OLD, listw=lw, pred.type = "TS", legacy=TRUE, power=TRUE, legacy.mixed = TRUE) -all.equal(p2, p5, check.attributes=FALSE) +all.equal(p2, p5, check.attributes=FALSE) #> [1] TRUE @@ -401,7 +401,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/sarlm_tests.html b/docs/reference/sarlm_tests.html index c6817e2..17f50d2 100644 --- a/docs/reference/sarlm_tests.html +++ b/docs/reference/sarlm_tests.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -253,7 +253,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/set.mcOption.html b/docs/reference/set.mcOption.html index 69cb155..e9c25d7 100644 --- a/docs/reference/set.mcOption.html +++ b/docs/reference/set.mcOption.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -111,9 +111,9 @@

Examples

#> [1] "cluster" "cores" "mc" "rlecuyerSeed" "verbose" #> [6] "zeroPolicy" library(parallel) -nc <- detectCores(logical=FALSE) +nc <- max(2L, detectCores(logical=FALSE), na.rm = TRUE)-1L nc -#> [1] 4 +#> [1] 5 # set nc to 1L here if (nc > 1L) nc <- 1L #nc <- ifelse(nc > 2L, 2L, nc) @@ -126,7 +126,7 @@

Examples

if(.Platform$OS.type == "windows") { # forking not permitted on Windows - start cluster # removed for Github actions 210502 -# \dontrun{ +if (FALSE) { print(get.mcOption()) cl <- makeCluster(get.coresOption()) print(clusterEvalQ(cl, exists("mom_calc"))) @@ -137,7 +137,7 @@

Examples

set.ClusterOption(NULL) print(clusterEvalQ(cl, exists("mom_calc"))) stopCluster(cl) -# } +} } else { mcOpt <- get.mcOption() print(mcOpt) @@ -185,7 +185,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/set.spChkOption.html b/docs/reference/set.spChkOption.html index dda29f9..889f6b5 100644 --- a/docs/reference/set.spChkOption.html +++ b/docs/reference/set.spChkOption.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -117,7 +117,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/similar.listw.html b/docs/reference/similar.listw.html index 319bddc..7229b44 100644 --- a/docs/reference/similar.listw.html +++ b/docs/reference/similar.listw.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -132,7 +132,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/sparse_mat.html b/docs/reference/sparse_mat.html index aebbf3f..e31d897 100644 --- a/docs/reference/sparse_mat.html +++ b/docs/reference/sparse_mat.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -115,7 +115,7 @@

See also

Examples

-
# \dontrun{
+    
if (FALSE) {
 require(sf, quietly=TRUE)
 columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
 #require(spdep, quietly=TRUE)
@@ -125,24 +125,6 @@ 

Examples

col.sp <- as.spam.listw(col.listw) str(col.sp) } -#> Spam version 2.9-1 (2022-08-07) is loaded. -#> Type 'help( Spam)' or 'demo( spam)' for a short introduction -#> and overview of this package. -#> Help for individual functions is also obtained by adding the -#> suffix '.spam' to the function name, e.g. 'help( chol.spam)'. -#> -#> Attaching package: ‘spam’ -#> The following object is masked from ‘package:Matrix’: -#> -#> det -#> The following objects are masked from ‘package:base’: -#> -#> backsolve, forwardsolve -#> Formal class 'spam' [package "spam"] with 4 slots -#> ..@ entries : num [1:230] 0.5 0.5 0.333 0.333 0.333 ... -#> ..@ colindices : int [1:230] 2 3 1 3 4 1 2 4 5 2 ... -#> ..@ rowpointers: int [1:50] 1 3 6 10 14 21 23 27 33 41 ... -#> ..@ dimension : int [1:2] 49 49 suppressMessages(nyadjmat <- as.matrix(foreign::read.dbf(system.file( "misc/nyadjwts.dbf", package="spData")[1])[-1])) nyadjlw <- spdep::mat2listw(nyadjmat) @@ -154,14 +136,11 @@

Examples

I <- Diagonal(n) rho <- 0.1 c(determinant(I - rho * W_S, logarithm=TRUE)$modulus) -#> [1] -9.587255 sum(log(1 - rho * eigenw(listw_NY))) -#> [1] -9.587255 nW <- - W_S nChol <- Cholesky(nW, Imult=8) n * log(rho) + (2 * c(determinant(update(nChol, nW, 1/rho))$modulus)) -#> [1] 99.8069 -# } +} nb7rt <- spdep::cell2nb(7, 7, torus=TRUE) x <- matrix(sample(rnorm(500*length(nb7rt))), nrow=length(nb7rt)) lw <- spdep::nb2listw(nb7rt) @@ -179,46 +158,33 @@

Examples

W <- as(lw, "CsparseMatrix") system.time(e <- invIrM(nb7rt, rho=0.98, method="solve", feasible=NULL) %*% x) #> user system elapsed -#> 0.004 0.000 0.004 +#> 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.212 0.003 0.224 +#> 0.185 0.004 0.189 str(attr(ee, "internal")) #> List of 5 -#> $ series: num [1:250] 0.287 0.234 0.201 0.178 0.16 ... +#> $ series: num [1:250] 0.286 0.233 0.199 0.175 0.157 ... #> $ order : num 250 #> $ tol : num 4.05e-10 #> $ iter : num 250 #> $ conv : logi FALSE -all.equal(e, as(ee, "matrix"), check.attributes=FALSE) -#> [1] "Mean relative difference: 0.0060747" -# \dontrun{ +all.equal(e, as(ee, "matrix"), check.attributes=FALSE) +#> [1] "Mean relative difference: 0.00604604" +if (FALSE) { system.time(ee <- powerWeights(W, rho=0.9, X=x)) -#> user system elapsed -#> 0.167 0.002 0.179 system.time(ee <- powerWeights(W, rho=0.98, order=1000, X=x)) -#> user system elapsed -#> 0.806 0.005 0.856 -all.equal(e, as(ee, "matrix"), check.attributes=FALSE) -#> [1] TRUE +all.equal(e, as(ee, "matrix"), check.attributes=FALSE) nb60rt <- spdep::cell2nb(60, 60, torus=TRUE) W <- as(spdep::nb2listw(nb60rt), "CsparseMatrix") set.seed(1) x <- matrix(rnorm(dim(W)[1]), ncol=1) system.time(ee <- powerWeights(W, rho=0.3, X=x)) -#> user system elapsed -#> 0.021 0.000 0.022 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") coefficients(obj) -#> lambda (Intercept) -#> 0.30639880 0.01380415 -# } +}
@@ -233,7 +199,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/spautolm.html b/docs/reference/spautolm.html index 614f4b5..c2b0db3 100644 --- a/docs/reference/spautolm.html +++ b/docs/reference/spautolm.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -329,55 +329,12 @@

See also

Examples

require("sf", quietly=TRUE)
 nydata <- st_read(system.file("shapes/NY8_bna_utm18.gpkg", package="spData")[1], quiet=TRUE)
-# \dontrun{
+if (FALSE) {
 lm0 <- lm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata)
 summary(lm0)
-#> 
-#> Call:
-#> lm(formula = Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data = nydata)
-#> 
-#> Residuals:
-#>     Min      1Q  Median      3Q     Max 
-#> -1.7417 -0.3957 -0.0326  0.3353  4.1398 
-#> 
-#> Coefficients:
-#>             Estimate Std. Error t value Pr(>|t|)    
-#> (Intercept) -0.51728    0.15856  -3.262  0.00124 ** 
-#> PEXPOSURE    0.04884    0.03506   1.393  0.16480    
-#> PCTAGE65P    3.95089    0.60550   6.525 3.22e-10 ***
-#> PCTOWNHOME  -0.56004    0.17031  -3.288  0.00114 ** 
-#> ---
-#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
-#> 
-#> Residual standard error: 0.6571 on 277 degrees of freedom
-#> Multiple R-squared:  0.1932,	Adjusted R-squared:  0.1844 
-#> F-statistic:  22.1 on 3 and 277 DF,  p-value: 7.306e-13
-#> 
 lm0w <- lm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, weights=POP8)
 summary(lm0w)
-#> 
-#> Call:
-#> lm(formula = Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data = nydata, 
-#>     weights = POP8)
-#> 
-#> Weighted Residuals:
-#>      Min       1Q   Median       3Q      Max 
-#> -129.067  -14.714    5.817   25.624   70.723 
-#> 
-#> Coefficients:
-#>             Estimate Std. Error t value Pr(>|t|)    
-#> (Intercept) -0.77837    0.14116  -5.514 8.03e-08 ***
-#> PEXPOSURE    0.07626    0.02731   2.792  0.00560 ** 
-#> PCTAGE65P    3.85656    0.57126   6.751 8.60e-11 ***
-#> PCTOWNHOME  -0.39869    0.15305  -2.605  0.00968 ** 
-#> ---
-#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
-#> 
-#> Residual standard error: 33.5 on 277 degrees of freedom
-#> Multiple R-squared:  0.1977,	Adjusted R-squared:  0.189 
-#> F-statistic: 22.75 on 3 and 277 DF,  p-value: 3.382e-13
-#> 
-# }
+}
 suppressMessages(nyadjmat <- as.matrix(foreign::read.dbf(system.file(
  "misc/nyadjwts.dbf", package="spData")[1])[-1]))
 suppressMessages(ID <- as.character(names(foreign::read.dbf(system.file(
@@ -386,263 +343,43 @@ 

Examples

#> [1] TRUE #require("spdep", quietly=TRUE) nyadjlw <- spdep::mat2listw(nyadjmat, as.character(nydata$AREAKEY)) +#> Warning: style is M (missing); style should be set to a valid value listw_NY <- spdep::nb2listw(nyadjlw$neighbours, style="B") eigs <- eigenw(listw_NY) -# \dontrun{ +if (FALSE) { esar0 <- errorsarlm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, listw=listw_NY) summary(esar0) -#> -#> Call:errorsarlm(formula = Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, -#> data = nydata, listw = listw_NY) -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -1.56754 -0.38239 -0.02643 0.33109 4.01219 -#> -#> Type: error -#> Coefficients: (asymptotic standard errors) -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) -0.618193 0.176784 -3.4969 0.0004707 -#> PEXPOSURE 0.071014 0.042051 1.6888 0.0912635 -#> PCTAGE65P 3.754200 0.624722 6.0094 1.862e-09 -#> PCTOWNHOME -0.419890 0.191329 -2.1946 0.0281930 -#> -#> Lambda: 0.040487, LR test value: 5.2438, p-value: 0.022026 -#> Asymptotic standard error: 0.016214 -#> z-value: 2.4971, p-value: 0.01252 -#> Wald statistic: 6.2356, p-value: 0.01252 -#> -#> Log likelihood: -276.1069 for error model -#> ML residual variance (sigma squared): 0.41388, (sigma: 0.64333) -#> Number of observations: 281 -#> Number of parameters estimated: 6 -#> AIC: 564.21, (AIC for lm: 567.46) -#> system.time(esar1f <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, listw=listw_NY, family="SAR", method="eigen", control=list(pre_eig=eigs))) -#> user system elapsed -#> 0.272 0.000 0.274 res <- summary(esar1f) print(res) -#> -#> Call: -#> spautolm(formula = Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data = nydata, -#> listw = listw_NY, family = "SAR", method = "eigen", control = list(pre_eig = eigs)) -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -1.56754 -0.38239 -0.02643 0.33109 4.01219 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) -0.618193 0.176784 -3.4969 0.0004707 -#> PEXPOSURE 0.071014 0.042051 1.6888 0.0912635 -#> PCTAGE65P 3.754200 0.624722 6.0094 1.862e-09 -#> PCTOWNHOME -0.419890 0.191329 -2.1946 0.0281930 -#> -#> Lambda: 0.040487 LR test value: 5.2438 p-value: 0.022026 -#> Numerical Hessian standard error of lambda: 0.017209 -#> -#> Log likelihood: -276.1069 -#> ML residual variance (sigma squared): 0.41388, (sigma: 0.64333) -#> Number of observations: 281 -#> Number of parameters estimated: 6 -#> AIC: 564.21 -#> coef(res) -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) -0.61819272 0.17678351 -3.496891 4.707136e-04 -#> PEXPOSURE 0.07101384 0.04205063 1.688770 9.126351e-02 -#> PCTAGE65P 3.75419997 0.62472153 6.009397 1.862141e-09 -#> PCTOWNHOME -0.41988961 0.19132936 -2.194591 2.819298e-02 sqrt(diag(res$resvar)) -#> (Intercept) PEXPOSURE PCTAGE65P PCTOWNHOME -#> 0.17678351 0.04205063 0.62472153 0.19132936 sqrt(diag(esar1f$fit$imat)*esar1f$fit$s2) -#> (Intercept) PEXPOSURE PCTAGE65P PCTOWNHOME -#> 0.17678351 0.04205063 0.62472153 0.19132936 sqrt(diag(esar1f$fdHess)) -#> [1] 0.01720868 0.18535631 0.04389387 0.63003835 0.20373413 system.time(esar1M <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, listw=listw_NY, family="SAR", method="Matrix")) -#> user system elapsed -#> 0.323 0.000 0.325 summary(esar1M) -#> -#> Call: -#> spautolm(formula = Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data = nydata, -#> listw = listw_NY, family = "SAR", method = "Matrix") -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -3.406132 -0.561646 -0.092662 0.474796 5.384405 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) -0.414826 0.102166 -4.0603 4.901e-05 -#> PEXPOSURE 0.015081 0.017772 0.8486 0.3961 -#> PCTAGE65P 5.159749 0.476498 10.8285 < 2.2e-16 -#> PCTOWNHOME -0.892387 0.099241 -8.9921 < 2.2e-16 -#> -#> Lambda: -0.38889 LR test value: 254.73 p-value: < 2.22e-16 -#> Numerical Hessian standard error of lambda: 0.044857 -#> -#> Log likelihood: -151.3662 -#> ML residual variance (sigma squared): 0.95111, (sigma: 0.97525) -#> Number of observations: 281 -#> Number of parameters estimated: 6 -#> AIC: 314.73 -#> system.time(esar1M <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, listw=listw_NY, family="SAR", method="Matrix", control=list(super=TRUE))) -#> user system elapsed -#> 0.282 0.000 0.283 summary(esar1M) -#> -#> Call: -#> spautolm(formula = Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data = nydata, -#> listw = listw_NY, family = "SAR", method = "Matrix", control = list(super = TRUE)) -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -3.178535 -0.521860 -0.074421 0.414212 5.184465 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) -0.411041 0.104426 -3.9362 8.279e-05 -#> PEXPOSURE 0.015768 0.018366 0.8585 0.3906 -#> PCTAGE65P 5.070130 0.483332 10.4900 < 2.2e-16 -#> PCTOWNHOME -0.880883 0.102093 -8.6282 < 2.2e-16 -#> -#> Lambda: -0.33146 LR test value: 247.44 p-value: < 2.22e-16 -#> Numerical Hessian standard error of lambda: 0.030659 -#> -#> Log likelihood: -155.0108 -#> ML residual variance (sigma squared): 0.82436, (sigma: 0.90795) -#> Number of observations: 281 -#> Number of parameters estimated: 6 -#> AIC: 322.02 -#> esar1wf <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, listw=listw_NY, weights=POP8, family="SAR", method="eigen", control=list(pre_eig=eigs)) summary(esar1wf) -#> -#> Call: -#> spautolm(formula = Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data = nydata, -#> listw = listw_NY, weights = POP8, family = "SAR", method = "eigen", -#> control = list(pre_eig = eigs)) -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -1.48488 -0.26823 0.09489 0.46552 4.28343 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) -0.797063 0.144054 -5.5331 3.146e-08 -#> PEXPOSURE 0.080545 0.028334 2.8428 0.004473 -#> PCTAGE65P 3.816731 0.576037 6.6258 3.453e-11 -#> PCTOWNHOME -0.380778 0.156507 -2.4330 0.014975 -#> -#> Lambda: 0.0095636 LR test value: 0.32665 p-value: 0.56764 -#> Numerical Hessian standard error of lambda: 0.016466 -#> -#> Log likelihood: -251.6017 -#> ML residual variance (sigma squared): 1104.1, (sigma: 33.229) -#> Number of observations: 281 -#> Number of parameters estimated: 6 -#> AIC: 515.2 -#> system.time(esar1wM <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, listw=listw_NY, weights=POP8, family="SAR", method="Matrix")) -#> user system elapsed -#> 0.320 0.000 0.322 summary(esar1wM) -#> -#> Call: -#> spautolm(formula = Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data = nydata, -#> listw = listw_NY, weights = POP8, family = "SAR", method = "Matrix") -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -2.561100 -0.374524 0.057405 0.591094 5.700142 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) -0.578546 0.090006 -6.4279 1.294e-10 -#> PEXPOSURE 0.035402 0.013959 2.5361 0.01121 -#> PCTAGE65P 4.651137 0.421285 11.0404 < 2.2e-16 -#> PCTOWNHOME -0.666898 0.091443 -7.2931 3.029e-13 -#> -#> Lambda: -0.34423 LR test value: 264.24 p-value: < 2.22e-16 -#> Numerical Hessian standard error of lambda: 0.036776 -#> -#> Log likelihood: -119.6468 -#> ML residual variance (sigma squared): 2129.1, (sigma: 46.142) -#> Number of observations: 281 -#> Number of parameters estimated: 6 -#> AIC: 251.29 -#> esar1wlu <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, listw=listw_NY, weights=POP8, family="SAR", method="LU") summary(esar1wlu) -#> -#> Call: -#> spautolm(formula = Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data = nydata, -#> listw = listw_NY, weights = POP8, family = "SAR", method = "LU") -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -1.48488 -0.26823 0.09489 0.46552 4.28343 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) -0.797063 0.144054 -5.5331 3.146e-08 -#> PEXPOSURE 0.080545 0.028334 2.8428 0.004473 -#> PCTAGE65P 3.816731 0.576037 6.6258 3.453e-11 -#> PCTOWNHOME -0.380778 0.156507 -2.4330 0.014975 -#> -#> Lambda: 0.0095636 LR test value: 0.32665 p-value: 0.56764 -#> Numerical Hessian standard error of lambda: 0.016522 -#> -#> Log likelihood: -251.6017 -#> ML residual variance (sigma squared): 1104.1, (sigma: 33.229) -#> Number of observations: 281 -#> Number of parameters estimated: 6 -#> AIC: 515.2 -#> esar1wch <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, listw=listw_NY, weights=POP8, family="SAR", method="Chebyshev") summary(esar1wch) -#> -#> Call: -#> spautolm(formula = Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data = nydata, -#> listw = listw_NY, weights = POP8, family = "SAR", method = "Chebyshev") -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -4.39831 -0.86303 0.12117 1.09320 8.78570 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) -0.538555 0.087573 -6.1498 7.76e-10 -#> PEXPOSURE 0.029782 0.013074 2.2780 0.02273 -#> PCTAGE65P 4.896346 0.419359 11.6758 < 2.2e-16 -#> PCTOWNHOME -0.737829 0.087569 -8.4257 < 2.2e-16 -#> -#> Lambda: -1 LR test value: 236970 p-value: < 2.22e-16 -#> Numerical Hessian standard error of lambda: NaN -#> -#> Log likelihood: 118232.5 -#> ML residual variance (sigma squared): 9336.4, (sigma: 96.625) -#> Number of observations: 281 -#> Number of parameters estimated: 6 -#> AIC: -236450 -#> -# } +} ecar1f <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, listw=listw_NY, family="CAR", method="eigen", control=list(pre_eig=eigs)) @@ -664,7 +401,7 @@

Examples

#> PCTOWNHOME -0.382789 0.195564 -1.9574 0.0503053 #> #> Lambda: 0.084123 LR test value: 5.8009 p-value: 0.016018 -#> Numerical Hessian standard error of lambda: 0.030868 +#> Numerical Hessian standard error of lambda: 0.030872 #> #> Log likelihood: -275.8283 #> ML residual variance (sigma squared): 0.40758, (sigma: 0.63842) @@ -672,38 +409,11 @@

Examples

#> Number of parameters estimated: 6 #> AIC: 563.66 #> -# \dontrun{ +if (FALSE) { system.time(ecar1M <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, listw=listw_NY, family="CAR", method="Matrix")) -#> user system elapsed -#> 0.349 0.000 0.350 summary(ecar1M) -#> -#> Call: -#> spautolm(formula = Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data = nydata, -#> listw = listw_NY, family = "CAR", method = "Matrix") -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -3.449951 -0.633777 -0.072436 0.550248 6.039594 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) -0.402788 0.112612 -3.5768 0.0003479 -#> PEXPOSURE 0.020131 0.020783 0.9686 0.3327222 -#> PCTAGE65P 4.632644 0.500526 9.2555 < 2.2e-16 -#> PCTOWNHOME -0.812981 0.112867 -7.2030 5.891e-13 -#> -#> Lambda: -0.5 LR test value: 228.48 p-value: < 2.22e-16 -#> Numerical Hessian standard error of lambda: NaN -#> -#> Log likelihood: -164.4897 -#> ML residual variance (sigma squared): 0.50386, (sigma: 0.70983) -#> Number of observations: 281 -#> Number of parameters estimated: 6 -#> AIC: 340.98 -#> -# } +} ecar1wf <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, listw=listw_NY, weights=POP8, family="CAR", method="eigen", control=list(pre_eig=eigs)) @@ -726,47 +436,20 @@

Examples

#> PCTOWNHOME -0.386820 0.157436 -2.4570 0.014010 #> #> Lambda: 0.022419 LR test value: 0.38785 p-value: 0.53343 -#> Numerical Hessian standard error of lambda: 0.038543 +#> Numerical Hessian standard error of lambda: 0.038977 #> #> Log likelihood: -251.5711 #> ML residual variance (sigma squared): 1102.9, (sigma: 33.21) #> Number of observations: 281 #> Number of parameters estimated: 6 -#> AIC: 515.14 +#> AIC: NA (not available for weighted model) #> -# \dontrun{ +if (FALSE) { system.time(ecar1wM <- spautolm(Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data=nydata, listw=listw_NY, weights=POP8, family="CAR", method="Matrix")) -#> user system elapsed -#> 0.342 0.000 0.344 summary(ecar1wM) -#> -#> Call: -#> spautolm(formula = Z ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME, data = nydata, -#> listw = listw_NY, weights = POP8, family = "CAR", method = "Matrix") -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -1.98144 -0.15716 0.37342 1.08857 7.10495 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) -0.714952 0.093905 -7.6136 2.665e-14 -#> PEXPOSURE 0.041467 0.015279 2.7139 0.00665 -#> PCTAGE65P 4.149207 0.425446 9.7526 < 2.2e-16 -#> PCTOWNHOME -0.478396 0.097030 -4.9304 8.205e-07 -#> -#> Lambda: -0.5 LR test value: 262.65 p-value: < 2.22e-16 -#> Numerical Hessian standard error of lambda: NaN -#> -#> Log likelihood: -120.4395 -#> ML residual variance (sigma squared): 1159.2, (sigma: 34.046) -#> Number of observations: 281 -#> Number of parameters estimated: 6 -#> AIC: 252.88 -#> -# } -# \dontrun{ +} +if (FALSE) { require("sf", quietly=TRUE) nc.sids <- st_read(system.file("shapes/sids.shp", package="spData")[1], quiet=TRUE) ft.SID74 <- sqrt(1000)*(sqrt(nc.sids$SID74/nc.sids$BIR74) + @@ -777,21 +460,18 @@

Examples

sids.nhbr30.dist <- spdep::nbdists(sids.nhbr30, cbind(nc.sids$east, nc.sids$north)) sids.nhbr <- spdep::listw2sn(spdep::nb2listw(sids.nhbr30, glist=sids.nhbr30.dist, style="B", zero.policy=TRUE)) -#> Warning: zero sum general weights dij <- sids.nhbr[,3] n <- nc.sids$BIR74 el1 <- min(dij)/dij el2 <- sqrt(n[sids.nhbr$to]/n[sids.nhbr$from]) sids.nhbr$weights <- el1*el2 sids.nhbr.listw <- spdep::sn2listw(sids.nhbr) -#> Warning: 56, 87 are not origins both <- factor(paste(nc.sids$L_id, nc.sids$M_id, sep=":")) ft.NWBIR74 <- sqrt(1000)*(sqrt(nc.sids$NWBIR74/nc.sids$BIR74) + sqrt((nc.sids$NWBIR74+1)/nc.sids$BIR74)) mdata <- data.frame(both, ft.NWBIR74, ft.SID74, BIR74=nc.sids$BIR74) outl <- which.max(rstandard(lm_nc)) as.character(nc.sids$NAME[outl]) -#> [1] "Anson" mdata.4 <- mdata[-outl,] W <- spdep::listw2mat(sids.nhbr.listw) W.4 <- W[-outl, -outl] @@ -799,395 +479,50 @@

Examples

esarI <- errorsarlm(ft.SID74 ~ 1, data=mdata, listw=sids.nhbr.listw, zero.policy=TRUE) summary(esarI) -#> -#> Call:errorsarlm(formula = ft.SID74 ~ 1, data = mdata, listw = sids.nhbr.listw, -#> zero.policy = TRUE) -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -1.887117 -0.636573 -0.043429 0.448767 3.406724 -#> -#> Type: error -#> Regions with no neighbours included: -#> 56 87 -#> Coefficients: (asymptotic standard errors) -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) 2.97463 0.13011 22.862 < 2.2e-16 -#> -#> Lambda: 0.66864, LR test value: 10.214, p-value: 0.0013939 -#> Asymptotic standard error: 0.11473 -#> z-value: 5.8278, p-value: 5.6147e-09 -#> Wald statistic: 33.964, p-value: 5.6147e-09 -#> -#> Log likelihood: -133.8616 for error model -#> ML residual variance (sigma squared): 0.81932, (sigma: 0.90516) -#> Number of observations: 100 -#> Number of parameters estimated: 3 -#> AIC: 273.72, (AIC for lm: 281.94) -#> esarIa <- spautolm(ft.SID74 ~ 1, data=mdata, listw=sids.nhbr.listw, family="SAR") summary(esarIa) -#> -#> Call: spautolm(formula = ft.SID74 ~ 1, data = mdata, listw = sids.nhbr.listw, -#> family = "SAR") -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -1.887117 -0.636573 -0.043429 0.448767 3.406724 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) 2.97463 0.13011 22.862 < 2.2e-16 -#> -#> Lambda: 0.66864 LR test value: 10.214 p-value: 0.0013939 -#> Numerical Hessian standard error of lambda: 0.16506 -#> -#> Log likelihood: -133.8616 -#> ML residual variance (sigma squared): 0.81932, (sigma: 0.90516) -#> Number of observations: 100 -#> Number of parameters estimated: 3 -#> AIC: 273.72 -#> esarIV <- errorsarlm(ft.SID74 ~ ft.NWBIR74, data=mdata, listw=sids.nhbr.listw, zero.policy=TRUE) summary(esarIV) -#> -#> Call: -#> errorsarlm(formula = ft.SID74 ~ ft.NWBIR74, data = mdata, listw = sids.nhbr.listw, -#> zero.policy = TRUE) -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -2.123648 -0.573163 0.017859 0.468022 2.693604 -#> -#> Type: error -#> Regions with no neighbours included: -#> 56 87 -#> Coefficients: (asymptotic standard errors) -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) 1.549443 0.219230 7.0677 1.576e-12 -#> ft.NWBIR74 0.041974 0.006171 6.8018 1.033e-11 -#> -#> Lambda: 0.18465, LR test value: 0.50496, p-value: 0.47733 -#> Asymptotic standard error: 0.20648 -#> z-value: 0.89424, p-value: 0.37119 -#> Wald statistic: 0.79967, p-value: 0.37119 -#> -#> Log likelihood: -117.7464 for error model -#> ML residual variance (sigma squared): 0.61546, (sigma: 0.78451) -#> Number of observations: 100 -#> Number of parameters estimated: 4 -#> AIC: 243.49, (AIC for lm: 242) -#> esarIVa <- spautolm(ft.SID74 ~ ft.NWBIR74, data=mdata, listw=sids.nhbr.listw, family="SAR") summary(esarIVa) -#> -#> Call: -#> spautolm(formula = ft.SID74 ~ ft.NWBIR74, data = mdata, listw = sids.nhbr.listw, -#> family = "SAR") -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -2.123648 -0.573163 0.017859 0.468022 2.693604 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) 1.549443 0.219230 7.0677 1.576e-12 -#> ft.NWBIR74 0.041974 0.006171 6.8018 1.033e-11 -#> -#> Lambda: 0.18465 LR test value: 0.50496 p-value: 0.47733 -#> Numerical Hessian standard error of lambda: 0.25591 -#> -#> Log likelihood: -117.7464 -#> ML residual variance (sigma squared): 0.61546, (sigma: 0.78451) -#> Number of observations: 100 -#> Number of parameters estimated: 4 -#> AIC: 243.49 -#> esarIaw <- spautolm(ft.SID74 ~ 1, data=mdata, listw=sids.nhbr.listw, weights=BIR74, family="SAR") summary(esarIaw) -#> -#> Call: spautolm(formula = ft.SID74 ~ 1, data = mdata, listw = sids.nhbr.listw, -#> weights = BIR74, family = "SAR") -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -1.867485 -0.568644 0.019717 0.502197 3.498013 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) 2.852052 0.090271 31.594 < 2.2e-16 -#> -#> Lambda: 0.7338 LR test value: 12.917 p-value: 0.00032554 -#> Numerical Hessian standard error of lambda: 0.13887 -#> -#> Log likelihood: -130.0975 -#> ML residual variance (sigma squared): 1539.4, (sigma: 39.236) -#> Number of observations: 100 -#> Number of parameters estimated: 3 -#> AIC: 266.19 -#> esarIIaw <- spautolm(ft.SID74 ~ both - 1, data=mdata, listw=sids.nhbr.listw, weights=BIR74, family="SAR") summary(esarIIaw) -#> -#> Call: -#> spautolm(formula = ft.SID74 ~ both - 1, data = mdata, listw = sids.nhbr.listw, -#> weights = BIR74, family = "SAR") -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -2.590809 -0.432976 0.016736 0.357284 3.536718 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> both1:2 2.05545 0.22184 9.2654 < 2.2e-16 -#> both1:3 2.87260 0.16181 17.7531 < 2.2e-16 -#> both1:4 4.16365 0.34330 12.1283 < 2.2e-16 -#> both2:1 2.47255 0.29757 8.3090 < 2.2e-16 -#> both2:2 2.15307 0.21172 10.1692 < 2.2e-16 -#> both2:3 2.64235 0.17296 15.2770 < 2.2e-16 -#> both2:4 3.26604 0.28287 11.5459 < 2.2e-16 -#> both3:1 3.11277 0.34166 9.1107 < 2.2e-16 -#> both3:2 2.76541 0.15667 17.6508 < 2.2e-16 -#> both3:3 2.86582 0.18593 15.4134 < 2.2e-16 -#> both3:4 3.18142 0.21617 14.7169 < 2.2e-16 -#> both4:3 3.69333 0.23348 15.8188 < 2.2e-16 -#> -#> Lambda: 0.32136 LR test value: 1.4004 p-value: 0.23666 -#> Numerical Hessian standard error of lambda: 0.25465 -#> -#> Log likelihood: -109.8922 -#> ML residual variance (sigma squared): 1071.6, (sigma: 32.735) -#> Number of observations: 100 -#> Number of parameters estimated: 14 -#> AIC: 247.78 -#> esarIVaw <- spautolm(ft.SID74 ~ ft.NWBIR74, data=mdata, listw=sids.nhbr.listw, weights=BIR74, family="SAR") summary(esarIVaw) -#> -#> Call: -#> spautolm(formula = ft.SID74 ~ ft.NWBIR74, data = mdata, listw = sids.nhbr.listw, -#> weights = BIR74, family = "SAR") -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -2.00956 -0.45229 0.12547 0.55952 2.92223 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) 1.5769279 0.2501334 6.3043 2.894e-10 -#> ft.NWBIR74 0.0368573 0.0069413 5.3099 1.097e-07 -#> -#> Lambda: 0.3839 LR test value: 1.9983 p-value: 0.15747 -#> Numerical Hessian standard error of lambda: 0.25769 -#> -#> Log likelihood: -119.5648 -#> ML residual variance (sigma squared): 1295.8, (sigma: 35.997) -#> Number of observations: 100 -#> Number of parameters estimated: 4 -#> AIC: 247.13 -#> ecarIaw <- spautolm(ft.SID74 ~ 1, data=mdata.4, listw=sids.nhbr.listw.4, weights=BIR74, family="CAR") -#> Warning: Non-symmetric spatial weights in CAR model summary(ecarIaw) -#> -#> Call: -#> spautolm(formula = ft.SID74 ~ 1, data = mdata.4, listw = sids.nhbr.listw.4, -#> weights = BIR74, family = "CAR") -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -2.009350 -0.638915 -0.060761 0.428526 2.019409 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) 2.942864 0.095304 30.879 < 2.2e-16 -#> -#> Lambda: 0.86832 LR test value: 23.003 p-value: 1.6172e-06 -#> Numerical Hessian standard error of lambda: 0.048102 -#> -#> Log likelihood: -118.7564 -#> ML residual variance (sigma squared): 1264, (sigma: 35.553) -#> Number of observations: 99 -#> Number of parameters estimated: 3 -#> AIC: 243.51 -#> ecarIIaw <- spautolm(ft.SID74 ~ both - 1, data=mdata.4, listw=sids.nhbr.listw.4, weights=BIR74, family="CAR") -#> Warning: Non-symmetric spatial weights in CAR model -#> Warning: NaNs produced summary(ecarIIaw) -#> -#> Call: -#> spautolm(formula = ft.SID74 ~ both - 1, data = mdata.4, listw = sids.nhbr.listw.4, -#> weights = BIR74, family = "CAR") -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -2.564067 -0.461531 -0.020982 0.384458 2.054255 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> both1:2 2.06282 0.20065 10.2806 < 2.2e-16 -#> both1:3 2.91982 0.14171 20.6048 < 2.2e-16 -#> both1:4 4.12159 0.30076 13.7037 < 2.2e-16 -#> both2:1 2.58281 0.27014 9.5611 < 2.2e-16 -#> both2:2 2.17549 0.18265 11.9104 < 2.2e-16 -#> both2:3 2.67030 0.15355 17.3910 < 2.2e-16 -#> both2:4 3.10806 0.24748 12.5588 < 2.2e-16 -#> both3:1 2.93237 0.30007 9.7724 < 2.2e-16 -#> both3:2 2.65317 0.14139 18.7646 < 2.2e-16 -#> both3:3 2.91685 0.17134 17.0234 < 2.2e-16 -#> both3:4 3.20447 0.20402 15.7063 < 2.2e-16 -#> both4:3 3.80672 0.20831 18.2742 < 2.2e-16 -#> -#> Lambda: 0.22163 LR test value: 1.3827 p-value: 0.23964 -#> Numerical Hessian standard error of lambda: NaN -#> -#> Log likelihood: -99.2181 -#> ML residual variance (sigma squared): 890.66, (sigma: 29.844) -#> Number of observations: 99 -#> Number of parameters estimated: 14 -#> AIC: 226.44 -#> ecarIVaw <- spautolm(ft.SID74 ~ ft.NWBIR74, data=mdata.4, listw=sids.nhbr.listw.4, weights=BIR74, family="CAR") -#> Warning: Non-symmetric spatial weights in CAR model summary(ecarIVaw) -#> -#> Call: -#> spautolm(formula = ft.SID74 ~ ft.NWBIR74, data = mdata.4, listw = sids.nhbr.listw.4, -#> weights = BIR74, family = "CAR") -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -1.99259 -0.44794 0.15464 0.60748 1.95751 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) 1.434705 0.225521 6.3618 1.995e-10 -#> ft.NWBIR74 0.040903 0.006299 6.4936 8.382e-11 -#> -#> Lambda: 0.22724 LR test value: 1.1936 p-value: 0.2746 -#> Numerical Hessian standard error of lambda: 0.55494 -#> -#> Log likelihood: -114.0196 -#> ML residual variance (sigma squared): 1201, (sigma: 34.655) -#> Number of observations: 99 -#> Number of parameters estimated: 4 -#> AIC: 236.04 -#> nc.sids$fitIV <- append(fitted.values(ecarIVaw), NA, outl-1) plot(nc.sids[,"fitIV"], nbreaks=12) # Cressie 1993, p. 565 - -# } -# \dontrun{ +} +if (FALSE) { data(oldcol, package="spdep") COL.errW.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, spdep::nb2listw(COL.nb, style="W")) summary(COL.errW.eig) -#> -#> Call: -#> errorsarlm(formula = CRIME ~ INC + HOVAL, data = COL.OLD, listw = spdep::nb2listw(COL.nb, -#> style = "W")) -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -34.81174 -6.44031 -0.72142 7.61476 23.33626 -#> -#> Type: error -#> Coefficients: (asymptotic standard errors) -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) 59.893219 5.366163 11.1613 < 2.2e-16 -#> INC -0.941312 0.330569 -2.8476 0.0044057 -#> HOVAL -0.302250 0.090476 -3.3407 0.0008358 -#> -#> Lambda: 0.56179, LR test value: 7.9935, p-value: 0.0046945 -#> Asymptotic standard error: 0.13387 -#> z-value: 4.1966, p-value: 2.7098e-05 -#> Wald statistic: 17.611, p-value: 2.7098e-05 -#> -#> Log likelihood: -183.3805 for error model -#> ML residual variance (sigma squared): 95.575, (sigma: 9.7762) -#> Number of observations: 49 -#> Number of parameters estimated: 5 -#> AIC: 376.76, (AIC for lm: 382.75) -#> COL.errW.sar <- spautolm(CRIME ~ INC + HOVAL, data=COL.OLD, spdep::nb2listw(COL.nb, style="W")) summary(COL.errW.sar) -#> -#> Call: -#> spautolm(formula = CRIME ~ INC + HOVAL, data = COL.OLD, listw = spdep::nb2listw(COL.nb, -#> style = "W")) -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -34.81174 -6.44031 -0.72142 7.61476 23.33626 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) 59.893219 5.366163 11.1613 < 2.2e-16 -#> INC -0.941312 0.330569 -2.8476 0.0044057 -#> HOVAL -0.302250 0.090476 -3.3407 0.0008358 -#> -#> Lambda: 0.56179 LR test value: 7.9935 p-value: 0.0046945 -#> Numerical Hessian standard error of lambda: 0.15242 -#> -#> Log likelihood: -183.3805 -#> ML residual variance (sigma squared): 95.575, (sigma: 9.7762) -#> Number of observations: 49 -#> Number of parameters estimated: 5 -#> AIC: 376.76 -#> data(boston, package="spData") gp1 <- spautolm(log(CMEDV) ~ CRIM + ZN + INDUS + CHAS + I(NOX^2) + I(RM^2) + AGE + log(DIS) + log(RAD) + TAX + PTRATIO + B + log(LSTAT), data=boston.c, spdep::nb2listw(boston.soi), family="SMA") summary(gp1) -#> -#> Call: spautolm(formula = log(CMEDV) ~ CRIM + ZN + INDUS + CHAS + I(NOX^2) + -#> I(RM^2) + AGE + log(DIS) + log(RAD) + TAX + PTRATIO + B + -#> log(LSTAT), data = boston.c, listw = spdep::nb2listw(boston.soi), -#> family = "SMA") -#> -#> Residuals: -#> Min 1Q Median 3Q Max -#> -0.5847694 -0.0713881 0.0012284 0.0827517 0.6071219 -#> -#> Coefficients: -#> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) 4.28501607 0.15367176 27.8842 < 2.2e-16 -#> CRIM -0.00718807 0.00106298 -6.7622 1.359e-11 -#> ZN 0.00023008 0.00051897 0.4433 0.6575185 -#> INDUS 0.00047300 0.00263339 0.1796 0.8574551 -#> CHAS1 0.01020698 0.02872047 0.3554 0.7222970 -#> I(NOX^2) -0.44885530 0.13675913 -3.2821 0.0010304 -#> I(RM^2) 0.00638094 0.00110330 5.7835 7.316e-09 -#> AGE -0.00043973 0.00051336 -0.8566 0.3916862 -#> log(DIS) -0.15650578 0.03856337 -4.0584 4.941e-05 -#> log(RAD) 0.07583760 0.02016468 3.7609 0.0001693 -#> TAX -0.00049364 0.00012162 -4.0588 4.933e-05 -#> PTRATIO -0.02494959 0.00538791 -4.6307 3.645e-06 -#> B 0.00048517 0.00010944 4.4334 9.277e-06 -#> log(LSTAT) -0.32961379 0.02353891 -14.0029 < 2.2e-16 -#> -#> Lambda: 0.61991 LR test value: 144.28 p-value: < 2.22e-16 -#> Numerical Hessian standard error of lambda: 0.044359 -#> -#> Log likelihood: 229.1208 -#> ML residual variance (sigma squared): 0.02596, (sigma: 0.16112) -#> Number of observations: 506 -#> Number of parameters estimated: 16 -#> AIC: -426.24 -#> -# } +}
@@ -1202,7 +537,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/stsls.html b/docs/reference/stsls.html index 9aadaf9..ed6230a 100644 --- a/docs/reference/stsls.html +++ b/docs/reference/stsls.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -196,7 +196,7 @@

Examples

#> Type: lag #> Coefficients: (asymptotic standard errors) #> Estimate Std. Error z value Pr(>|z|) -#> (Intercept) 45.079251 7.177347 6.2808 3.369e-10 +#> (Intercept) 45.079250 7.177347 6.2808 3.369e-10 #> INC -1.031616 0.305143 -3.3808 0.0007229 #> HOVAL -0.265926 0.088499 -3.0049 0.0026570 #> @@ -209,9 +209,9 @@

Examples

#> ML residual variance (sigma squared): 95.494, (sigma: 9.7721) #> Number of observations: 49 #> Number of parameters estimated: 5 -#> AIC: 374.78, (AIC for lm: 382.75) +#> AIC: NA (not available for weighted model), (AIC for lm: 382.75) #> LM test for residual autocorrelation -#> test value: 0.31955, p-value: 0.57188 +#> test value: 0.31954, p-value: 0.57188 #> #> Correlation of coefficients #> sigma rho (Intercept) INC @@ -262,19 +262,19 @@

Examples

#> Simulation results ( variance matrix): #> ======================================================== #> Simulated standard errors -#> Direct Indirect Total -#> INC 0.39668006 0.9695180 1.0529050 -#> HOVAL 0.09757127 0.3123932 0.3649017 +#> Direct Indirect Total +#> INC 0.4250637 0.7860257 0.9598058 +#> HOVAL 0.1068486 0.6601511 0.7218709 #> #> Simulated z-values: -#> Direct Indirect Total -#> INC -2.768354 -0.8583926 -1.833383 -#> HOVAL -2.954457 -0.8425926 -1.511339 +#> Direct Indirect Total +#> INC -2.474018 -1.0625140 -1.9657924 +#> HOVAL -2.826222 -0.4999244 -0.8755077 #> #> Simulated p-values: #> Direct Indirect Total -#> INC 0.0056340 0.39068 0.066746 -#> HOVAL 0.0031322 0.39946 0.130702 +#> INC 0.0133603 0.28800 0.049323 +#> HOVAL 0.0047101 0.61713 0.381298 ev <- eigenw(lw) loobj2 <- impacts(COL.lag.stsls, R=200, evalues=ev) summary(loobj2, zstats=TRUE, short=TRUE) @@ -287,23 +287,23 @@

Examples

#> ======================================================== #> Simulated standard errors #> Direct Indirect Total -#> INC 0.3841092 0.7160775 0.8241613 -#> HOVAL 0.1008357 0.4126274 0.4698167 +#> INC 0.3647280 1.2688013 1.3886153 +#> HOVAL 0.1175608 0.8263993 0.9011554 #> #> Simulated z-values: -#> Direct Indirect Total -#> INC -2.895776 -1.1602746 -2.357719 -#> HOVAL -2.743940 -0.6064747 -1.121576 +#> Direct Indirect Total +#> INC -2.955756 -0.7150236 -1.4296758 +#> HOVAL -2.404673 -0.4145933 -0.6939034 #> #> Simulated p-values: -#> Direct Indirect Total -#> INC 0.0037822 0.24594 0.018388 -#> HOVAL 0.0060707 0.54420 0.262043 +#> Direct Indirect Total +#> INC 0.003119 0.47459 0.15281 +#> HOVAL 0.016187 0.67844 0.48774 require(coda) HPDinterval(loobj1) -#> lower upper -#> INC -1.7799556 -0.35225230 -#> HOVAL -0.4587508 -0.09515137 +#> lower upper +#> INC -1.8854657 -0.2997080 +#> HOVAL -0.4662763 -0.1121351 #> attr(,"Probability") #> [1] 0.95 COL.lag.stslsW <- stsls(CRIME ~ INC + HOVAL, data=COL.OLD, lw, W2X=FALSE) @@ -431,7 +431,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/trW-1.png b/docs/reference/trW-1.png index ee43e54..d441164 100644 Binary files a/docs/reference/trW-1.png and b/docs/reference/trW-1.png differ diff --git a/docs/reference/trW.html b/docs/reference/trW.html index f15bc27..fae3239 100644 --- a/docs/reference/trW.html +++ b/docs/reference/trW.html @@ -17,7 +17,7 @@ spatialreg - 1.2-7 + 1.3-1 @@ -140,21 +140,21 @@

Examples

W <- as(listw, "CsparseMatrix") system.time(trMat <- trW(W, type="mult")) #> user system elapsed -#> 0.014 0.000 0.015 +#> 0.002 0.000 0.003 str(trMat) #> num [1:30] 0 10.91 3.65 5.62 3.66 ... -#> - attr(*, "timings")= Named num [1:2] 0.014 0.015 +#> - attr(*, "timings")= Named num [1:2] 0.002 0.003 #> ..- attr(*, "names")= chr [1:2] "user.self" "elapsed" #> - attr(*, "type")= chr "mult" #> - attr(*, "n")= int 49 set.seed(1100) system.time(trMC <- trW(W, type="MC")) #> user system elapsed -#> 0.011 0.000 0.011 +#> 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.011 0.011 +#> - 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,52 +169,45 @@

Examples

W <- forceSymmetric(as(listwS, "CsparseMatrix")) system.time(trmom <- trW(listw=listwS, m=24, type="moments")) #> user system elapsed -#> 0.003 0.000 0.003 +#> 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.003 0.003 +#> - 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 -all.equal(trMat[1:24], trmom, check.attributes=FALSE) +all.equal(trMat[1:24], trmom, check.attributes=FALSE) #> [1] TRUE system.time(trMat <- trW(W, m=24, type="mult")) #> user system elapsed -#> 0.011 0.000 0.011 +#> 0.002 0.000 0.003 str(trMat) #> num [1:24] 0 10.91 3.65 5.62 3.66 ... -#> - attr(*, "timings")= Named num [1:2] 0.011 0.011 +#> - attr(*, "timings")= Named num [1:2] 0.002 0.003 #> ..- attr(*, "names")= chr [1:2] "user.self" "elapsed" #> - attr(*, "type")= chr "mult" #> - attr(*, "n")= int 49 -all.equal(trMat, trmom, check.attributes=FALSE) +all.equal(trMat, trmom, check.attributes=FALSE) #> [1] TRUE set.seed(1) system.time(trMC <- trW(W, m=24, type="MC")) #> user system elapsed -#> 0.013 0.000 0.013 +#> 0.007 0.000 0.007 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.013 0.013 +#> - attr(*, "timings")= Named num [1:2] 0.007 0.007 #> ..- attr(*, "names")= chr [1:2] "user.self" "elapsed" #> - attr(*, "type")= chr "MC" #> - attr(*, "n")= int 49 -# \dontrun{ +if (FALSE) { data(boston, package="spData") listw <- spdep::nb2listw(boston.soi) listwS <- similar.listw(listw) system.time(trmom <- trW(listw=listwS, m=24, type="moments")) -#> user system elapsed -#> 0.146 0.000 0.146 str(trmom) -#> num [1:24] 0 124.2 32.7 63.7 33.2 ... -#> - attr(*, "timings")= Named num [1:2] 0.146 0.146 -#> ..- attr(*, "names")= chr [1:2] "user.self" "elapsed" -#> - attr(*, "type")= chr "moments" -#> - attr(*, "n")= int 506 library(parallel) -nc <- detectCores(logical=FALSE) +nc <- max(2L, detectCores(logical=FALSE), na.rm = TRUE)-1L # set nc to 1L here if (nc > 1L) nc <- 1L coresOpt <- get.coresOption() @@ -224,16 +217,13 @@

Examples

set.ClusterOption(cl) } system.time(trmomp <- trW(listw=listwS, m=24, type="moments")) -#> user system elapsed -#> 0.144 0.000 0.144 if(!get.mcOption()) { set.ClusterOption(NULL) stopCluster(cl) } -all.equal(trmom, trmomp, check.attributes=FALSE) -#> [1] TRUE +all.equal(trmom, trmomp, check.attributes=FALSE) invisible(set.coresOption(coresOpt)) -# } +}
@@ -248,7 +238,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.