I like it apsrtable(), and it was a little easier for me to extend to other classes (in particular, I adapted it for objects mlogit. But for some reason, the function apsrtableSummary.sarlm()does not work just like the other hacks I wrote.
As a rule, we need to redefine the coefficient matrix so that we apsrtable()know where to find it. Code for this
"apsrtableSummary.sarlm" <- function (x){
s <- summary(x)
s$coefficients <- s$Coef
return(s)
}
We also need to override modelInfofor the new class, for example:
setMethod("modelInfo", "summary.sarlm", function(x){
env <- sys.parent()
digits <- evalq(digits, envir=env)
model.info <- list(
"$\\rho$" = formatC(x$rho, format="f", digits=digits),
"$p(\\rho)$" = formatC(x$LR1$p.value, format="f", digits=digits),
"$N$" = length(x$fitted.values),
"AIC" = formatC(AIC(x), format="f", digits=digits),
"\\mathcal{L}" = formatC(x$LL, format="f", digits=digits)
)
class(model.info) <- "model.info"
return(model.info)
})
However, after defining these two functions, the call apsrtable()does not display the coefficients (MWE uses the example from lagsarlmin the packet spdep).
library(spdep)
library(apsrtable)
data(oldcol)
COL.lag.eig <- lagsarlm(CRIME ~ INC + HOVAL, data=COL.OLD,
nb2listw(COL.nb, style="W"), method="eigen")
summary(COL.lag.eig)
apsrtable(COL.lag.eig)
\begin{table}[!ht]
\caption{}
\label{}
\begin{tabular}{ l D{.}{.}{2} }
\hline
& \multicolumn{ 1 }{ c }{ Model 1 } \\ \hline
% & Model 1 \\
$\rho$.rho & 0.43 \\
$p(\rho)$.Likelihood ratio & 0.00 \\
$N$ & 49 \\
AIC & 374.78 \\
\mathcal{L} & -182.39 \\ \hline
\multicolumn{2}{l}{\footnotesize{Standard errors in parentheses}}\\
\multicolumn{2}{l}{\footnotesize{$^*$ indicates significance at $p< 0.05 $}}
\end{tabular}
\end{table}
, , , . , ,
apsrtableSummary(COL.lag.eig)$coefficients
Estimate Std. Error z value Pr(>|z|)
(Intercept) 45.0792505 7.17734654 6.280768 3.369041e-10
INC -1.0316157 0.30514297 -3.380762 7.228517e-04
HOVAL -0.2659263 0.08849862 -3.004863 2.657002e-03
, . ?