MyNixOS website logo
Description

Spatial-X (SLX) Models for Applied Researchers.

Tools for estimating, interpreting, and visualizing Spatial-X (SLX) regression models. Provides a formula-based interface with first-class support for variable-specific weights matrices, higher-order spatial lags, temporally-lagged spatial variables (TSLS), and tidy effects decomposition (direct, indirect, total). Designed to lower the barrier to SLX modeling for applied researchers who already work with 'sf' and 'lm'-style formulas. Methods follow Wimpy, Whitten, and Williams (2021) <doi:10.1086/710089>.

slxr slxr package hex sticker

R-CMD-check pkgdown Lifecycle: experimental

Documentation: https://cwimpy.github.io/slxr/

Spatial-X (SLX) models for applied researchers.

slxr makes it easy to fit, interpret, and visualize Spatial-X regression models in R. Unlike existing tools that treat SLX as a consolation prize for SAR, slxr centers the SLX approach and provides first-class support for the features applied researchers actually need:

  • Formula-based interface — write slx(y ~ x1 + x2, data, W, lag = "x1") and get a fitted model, not a wrestling match with listw objects.
  • Variable-specific weights matrices — the defining feature of Wimpy, Whitten, and Williams (2021). Different covariates can spill over through different W matrices (contiguity, alliance, trade, etc.) in a single model.
  • Higher-order spatial lags (W, , ) with clean effects decomposition.
  • Temporally-lagged spatial variables (TSLS) for panel data.
  • Tidy direct, indirect, and total effects — for SLX these don't require matrix inversion or simulation.
  • modelsummary-compatible output (via tidy() and glance() methods).
  • Sensible defaults plus diagnostics for comparing W specifications.

Installation

# Development version
# install.packages("remotes")
remotes::install_github("cwimpy/slxr")

Example

library(slxr)
data(defense_burden)   # 1995 cross-section from Wimpy et al. (2021)

W_contig   <- slx_weights(style = "custom", matrix = defense_burden$W_contig,
                          row_standardize = FALSE)
W_alliance <- slx_weights(style = "custom", matrix = defense_burden$W_alliance,
                          row_standardize = FALSE)
W_defense  <- slx_weights(style = "custom", matrix = defense_burden$W_defense,
                          row_standardize = FALSE)

fit <- slx(
  ch_milex ~ milex_tm1 + log_pop_tm1 + civilwar_tm1 + total_wars_tm1 +
             alliance_us + ch_milex_us + ch_milex_ussr,
  data = defense_burden$data,
  spatial = list(
    civilwar_tm1   = W_contig,
    total_wars_tm1 = list(contig = W_contig, alliance = W_alliance),
    milex_tm1      = list(contig = W_contig, defense  = W_defense)
  )
)

slx_effects(fit)
slx_plot_effects(fit, types = c("indirect", "total"))

SLX effects plot

Variable-specific weights matrices:

fit <- slx(defense ~ civil_war + interstate_war + defense_lag,
           data = df,
           spatial = list(
             civil_war      = W_contig,
             interstate_war = W_contig,
             defense_lag    = list(W_contig, W_pact)
           ))

Status

Early development. The MVP covers single-W SLX estimation, effects decomposition, and modelsummary integration. Multi-W, higher-order, temporal, and plotting features are on the roadmap.

Citation

If you use slxr in published work, please cite both the package and the methodological paper it implements. Run citation("slxr") in R to see the current BibTeX entry, or refer to:

  • Wimpy, C., Whitten, G. D., & Williams, L. K. (2021). X Marks the Spot: Unlocking the Treasure of Spatial-X Models. Journal of Politics, 83(2), 722–739. doi:10.1086/710089
  • Wimpy, C. (2026). slxr: Spatial-X (SLX) Models for Applied Researchers. R package version 0.1.0. https://cwimpy.github.io/slxr/

References

Wimpy, C., Whitten, G. D., & Williams, L. K. (2021). X Marks the Spot: Unlocking the Treasure of Spatial-X Models. Journal of Politics, 83(2), 722–739. doi:10.1086/710089

Vega, S. H., & Elhorst, J. P. (2015). The SLX Model. Journal of Regional Science, 55(3), 339–363.

LeSage, J. P., & Pace, R. K. (2009). Introduction to Spatial Econometrics. Chapman & Hall/CRC.

Metadata

Version

0.1.1

License

Unknown

Platforms (80)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows