These methods tidy the coefficients of spatial autoregression
models generated by functions in the spatialreg
package.
# S3 method for sarlm
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
An object returned from spatialreg::lagsarlm()
or spatialreg::errorsarlm()
.
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to FALSE
.
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 pass conf.lvel = 0.9
, all computation will
proceed using conf.level = 0.95
. Additionally, if you pass
newdata = my_tibble
to an augment()
method that does not
accept a newdata
argument, it will use the default value for
the data
argument.
tidy()
, spatialreg::lagsarlm()
, spatialreg::errorsarlm()
,
spatialreg::sacsarlm()
Other spatialreg tidiers:
augment.sarlm()
,
glance.sarlm()
A tibble::tibble()
with columns:
Upper bound on the confidence interval for the estimate.
Lower bound on the confidence interval for the estimate.
The estimated value of the regression term.
The two-sided p-value associated with the observed statistic.
The value of a T-statistic to use in a hypothesis that the regression term is non-zero.
The standard error of the regression term.
The name of the regression term.
# feel free to ignore the following two lines—they allow {broom} to supply
# examples without requiring the model-supplying packages to be installed.
if (requireNamespace("spdep", quietly = TRUE)) {
if (requireNamespace("spatialreg", quietly = TRUE)) {
# 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)
tidy(crime_sar, conf.int = TRUE)
glance(crime_sar)
augment(crime_sar)
# fit another model
crime_sem <- errorsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw)
# summarize model fit with tidiers
tidy(crime_sem)
tidy(crime_sem, conf.int = TRUE)
glance(crime_sem)
augment(crime_sem)
# fit another model
crime_sac <- sacsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw)
# summarize model fit with tidiers
tidy(crime_sac)
tidy(crime_sac, conf.int = TRUE)
glance(crime_sac)
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
#> # … with 39 more rows