Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8589317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:01:32+00:00 2026-06-11T23:01:32+00:00

I love apsrtable() , and have found it somewhat simple to extend to other

  • 0

I love apsrtable(), and have found it somewhat simple to extend to other classes (in particular, I have adapted it for mlogit objects. But for some reason, the apsrtableSummary.sarlm() function doesn’t work quite like other hacks I have written.

Typically, we need to redefine the coefficients matrix so that apsrtable() knows where to find it. The code for this is

"apsrtableSummary.sarlm" <- function (x){
  s <- summary(x)
  s$coefficients <- s$Coef
  return(s)
}

We also need to redefine the modelInfo for the new class, like this:

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)
})

After defining these two functions however, a call to apsrtable() doesn’t print the coefficients (MWE using example from lagsarlm in spdep package).

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)
# Load functions above
apsrtable(COL.lag.eig)

## OUTPUT ##
\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}

As you can see, everything works out great except for that the coefficients and standard errors are not there. It’s clear that the summary redefinition works, because

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

I’ve pulled my hair out for several days trying to find a way out of this. Any tips?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:01:33+00:00Added an answer on June 11, 2026 at 11:01 pm

    Well, I think I may be the only person on earth who uses both of these packages together, but I figured out a way to work through this problem.

    It turns out that the source of the error is in the coef method for summary.sarlm class objects. Typically this method returns a matrix with the coefficients table, but for this class it just returns the coefficients. The following code fixes that problem.

    setMethod("coef", "apsrtableSummary.sarlm", function(object) object$coefficients)
    

    I also found it useful to include the rho term as a model coefficient (the methods are not consistent on this).

    apsrtableSummary.sarlm <- function (x){
      s <- summary(x)
      s$rholine<- c(unname(s$rho), s$rho.se, unname(s$rho/s$rho.se),
                    unname(2 * (1 - pnorm(abs(s$rho/s$rho.se)))))
      s$Coef <- rbind(s$rholine, s$Coef)
      rownames(s$Coef)[1] <- "$\\rho$"
      s$coefficients <- s$Coef
      return(s)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I love my GUID. However, lately I have been doing some research to understand
I love paredit. But there are a couple of things I hate, and have
I love jQuery. I am probably going to have some XML parsing and manipulation
I love KnockoutJS but have been struggling to figure out the best way to
Would love some help here. I'm sure it's simple enough, I'm just a bit
I love MXML but am starting to notice some of its drawbacks. The main
Love the JQuery Treewiev plugin http://bassistance.de/jquery-plugins/jquery-plugin-treeview/ , but I have one problem with it.
I love using Haml helpers, but over the years things have changed a bit.
I love text mate, but sometimes I do miss some IDE features. One of
I love to Extend my Assert.AreEqual to many different classes, the known one is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.