These methods tidy the coefficients of spatial autoregression
models generated by functions in the spatialreg
package.
Usage
# S3 method for class 'sarlm'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
- x
An object returned from
spatialreg::lagsarlm()
orspatialreg::errorsarlm()
.- conf.int
Logical indicating whether or not to include a confidence interval in the tidied output. Defaults to
FALSE
.- conf.level
The confidence level to use for the confidence interval if
conf.int = TRUE
. Must be strictly greater than 0 and less than 1. Defaults to 0.95, which corresponds to a 95 percent confidence interval.- ...
Additional arguments. Not used. Needed to match generic signature only. Cautionary note: Misspelled arguments will be absorbed in
...
, where they will be ignored. If the misspelled argument has a default value, the default value will be used. For example, if you passconf.lvel = 0.9
, all computation will proceed usingconf.level = 0.95
. Two exceptions here are:
See also
tidy()
, spatialreg::lagsarlm()
, spatialreg::errorsarlm()
,
spatialreg::sacsarlm()
Other spatialreg tidiers:
augment.sarlm()
,
glance.sarlm()
Value
A tibble::tibble()
with columns:
- conf.high
Upper bound on the confidence interval for the estimate.
- conf.low
Lower bound on the confidence interval for the estimate.
- estimate
The estimated value of the regression term.
- p.value
The two-sided p-value associated with the observed statistic.
- statistic
The value of a T-statistic to use in a hypothesis that the regression term is non-zero.
- std.error
The standard error of the regression term.
- term
The name of the regression term.
Examples
# load libraries for models and data
library(spatialreg)
library(spdep)
# load data
data(oldcol, package = "spdep")
listw <- nb2listw(COL.nb, style = "W")
# fit model
crime_sar <-
lagsarlm(CRIME ~ INC + HOVAL,
data = COL.OLD,
listw = listw,
method = "eigen"
)
# summarize model fit with tidiers
tidy(crime_sar)
#> # A tibble: 4 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 rho 0.431 0.118 3.66 2.50e- 4
#> 2 (Intercept) 45.1 7.18 6.28 3.37e-10
#> 3 INC -1.03 0.305 -3.38 7.23e- 4
#> 4 HOVAL -0.266 0.0885 -3.00 2.66e- 3
tidy(crime_sar, conf.int = TRUE)
#> # A tibble: 4 × 7
#> term estimate std.error statistic p.value conf.low conf.high
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 rho 0.431 0.118 3.66 2.50e- 4 0.200 0.662
#> 2 (Intercept) 45.1 7.18 6.28 3.37e-10 31.0 59.1
#> 3 INC -1.03 0.305 -3.38 7.23e- 4 -1.63 -0.434
#> 4 HOVAL -0.266 0.0885 -3.00 2.66e- 3 -0.439 -0.0925
glance(crime_sar)
#> # A tibble: 1 × 6
#> r.squared AIC BIC deviance logLik nobs
#> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
#> 1 0.652 375. 384. 4679. -182. 49
augment(crime_sar)
#> # A tibble: 49 × 6
#> `(Intercept)` INC HOVAL CRIME .fitted .resid
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 21.2 44.6 18.8 22.6 -3.84
#> 2 1 4.48 33.2 32.4 46.6 -14.2
#> 3 1 11.3 37.1 38.4 41.4 -2.97
#> 4 1 8.44 75 0.178 37.9 -37.7
#> 5 1 19.5 80.5 15.7 14.2 1.54
#> 6 1 16.0 26.4 30.6 34.3 -3.66
#> 7 1 11.3 23.2 50.7 44.7 5.99
#> 8 1 16.0 28.8 26.1 38.4 -12.3
#> 9 1 9.87 18 48.6 51.7 -3.12
#> 10 1 13.6 96.4 34.0 16.3 17.7
#> # ℹ 39 more rows
# fit another model
crime_sem <- errorsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw)
# summarize model fit with tidiers
tidy(crime_sem)
#> # A tibble: 4 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 (Intercept) 59.9 5.37 11.2 0
#> 2 INC -0.941 0.331 -2.85 0.00441
#> 3 HOVAL -0.302 0.0905 -3.34 0.000836
#> 4 lambda 0.562 0.134 4.20 0.0000271
tidy(crime_sem, conf.int = TRUE)
#> # A tibble: 4 × 7
#> term estimate std.error statistic p.value conf.low conf.high
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 (Intercept) 59.9 5.37 11.2 0 49.4 70.4
#> 2 INC -0.941 0.331 -2.85 0.00441 -1.59 -0.293
#> 3 HOVAL -0.302 0.0905 -3.34 0.000836 -0.480 -0.125
#> 4 lambda 0.562 0.134 4.20 0.0000271 0.299 0.824
glance(crime_sem)
#> # A tibble: 1 × 6
#> r.squared AIC BIC deviance logLik nobs
#> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
#> 1 0.658 377. 386. 4683. -183. 49
augment(crime_sem)
#> # A tibble: 49 × 6
#> `(Intercept)` INC HOVAL CRIME .fitted .resid
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 21.2 44.6 18.8 22.5 -3.70
#> 2 1 4.48 33.2 32.4 44.9 -12.5
#> 3 1 11.3 37.1 38.4 38.2 0.223
#> 4 1 8.44 75 0.178 35.0 -34.8
#> 5 1 19.5 80.5 15.7 13.3 2.45
#> 6 1 16.0 26.4 30.6 35.0 -4.33
#> 7 1 11.3 23.2 50.7 42.3 8.41
#> 8 1 16.0 28.8 26.1 39.4 -13.3
#> 9 1 9.87 18 48.6 49.3 -0.721
#> 10 1 13.6 96.4 34.0 16.6 17.4
#> # ℹ 39 more rows
# fit another model
crime_sac <- sacsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw)
# summarize model fit with tidiers
tidy(crime_sac)
#> # A tibble: 5 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 rho 0.368 0.197 1.87 0.0613
#> 2 (Intercept) 47.8 9.90 4.83 0.00000140
#> 3 INC -1.03 0.326 -3.14 0.00167
#> 4 HOVAL -0.282 0.0900 -3.13 0.00176
#> 5 lambda 0.167 0.297 0.562 0.574
tidy(crime_sac, conf.int = TRUE)
#> # A tibble: 5 × 7
#> term estimate std.error statistic p.value conf.low conf.high
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 rho 0.368 0.197 1.87 0.0613 -0.0174 0.754
#> 2 (Intercept) 47.8 9.90 4.83 0.00000140 28.4 67.2
#> 3 INC -1.03 0.326 -3.14 0.00167 -1.67 -0.386
#> 4 HOVAL -0.282 0.0900 -3.13 0.00176 -0.458 -0.105
#> 5 lambda 0.167 0.297 0.562 0.574 -0.415 0.748
glance(crime_sac)
#> # A tibble: 1 × 6
#> r.squared AIC BIC deviance logLik nobs
#> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
#> 1 0.652 376. 388. 4685. -182. 49
augment(crime_sac)
#> # A tibble: 49 × 6
#> `(Intercept)` INC HOVAL CRIME .fitted .resid
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 21.2 44.6 18.8 22.2 -3.37
#> 2 1 4.48 33.2 32.4 46.4 -14.0
#> 3 1 11.3 37.1 38.4 40.4 -2.00
#> 4 1 8.44 75 0.178 37.5 -37.3
#> 5 1 19.5 80.5 15.7 13.5 2.25
#> 6 1 16.0 26.4 30.6 34.4 -3.74
#> 7 1 11.3 23.2 50.7 44.1 6.60
#> 8 1 16.0 28.8 26.1 39.0 -12.9
#> 9 1 9.87 18 48.6 51.5 -2.93
#> 10 1 13.6 96.4 34.0 15.8 18.2
#> # ℹ 39 more rows