I am using spdep
to run a spatial regression using a Durbin lag model. This type of model returns direct, indirect and total effects for each regression coefficient and their level of significance.
Is there an R
library like texreg
that organizes in a nice way the output of a Durbin lag model with information about direct, indirect and total effects?
Reproducible example:
library(spdep)
example(columbus)
listw <- nb2listw(col.gal.nb)
# spatial regression - Durbin Model
mobj <- lagsarlm(CRIME ~ INC + HOVAL, columbus, listw, type="mixed")
summary(mobj)
# Calculate direct and indirect impacts
W <- as(listw, "CsparseMatrix")
trMatc <- trW(W, type="mult")
trMC <- trW(W, type="MC")
imp <- impacts(mobj, tr=trMC, R=100)
sums <- summary(imp, zstats=T)
# Return Effects
data.frame(sums$res)
# Return p-values
data.frame(sums$pzmat)
I'm not sure if there's an existing function to create a nice looking table for this type of model object, but (with some effort) you can roll your own.
Below is an
rmarkdown
document with your code plus three additional code chunks. The first combines the coefficient and p-value data. The next two generate two different options forlatex
tables.I used
sums$res
andsums$pzmat
for the table values,tidyverse
functions to combine the coefficient estimates and p-values and edit the column names, and thekable
andkableExtra
packages to produce the latex output.rmarkdown
documentPDF output document