[R] memisc-Tables with robost standard errors

Achim Zeileis Achim.Zeileis at uibk.ac.at
Thu Jan 6 02:37:38 CET 2011


On Thu, 6 Jan 2011, Jan Henckens wrote:

> Hello,
>
> I've got a question concerning the usage of robust standard errors in 
> regression using lm() and exporting the summaries to LaTeX using the 
> memisc-packages function mtable():
>
> Is there any possibility to use robust errors which are obtained by vcovHC() 
> when generating the LateX-output by mtable()?
>
> I tried to manipulate the lm-object by appending the "new" covariance matrix 
> but mtable seems to generate the summary itself since it is not possible to 
> call mtable(summary(lm1)).

I'm not a "memisc" user but had a quick look at the mtable() function. It 
seems to rely on specification of some function getSummary() which 
produces the numbers that are displayed.

By default the getSummary() method for "lm" objects is called which 
contains a list element "coefs" with the coefficient table and confidence 
intervals. So one quick hack would be to modify that to employ robust 
standard errors:

mySummary <- function(obj, alpha = 0.05, ...) {
   ## get original summary
   s <- getSummary(obj, alpha = alpha, ...)

   ## replace Wald tests of coefficients
   s$coef[,1:4] <- coeftest(obj, vcov = vcovHC(obj))

   ## replace confidence intervals
   crit <- qt(alpha/2, obj$df.residual)
   s$coef[,5] <- s$coef[,1] + crit * s$coef[,2]
   s$coef[,6] <- s$coef[,1] - crit * s$coef[,2]

   return(s)
}

Then you can do

   mtable(lm1, getSummary = mySummary)

and add also all the other options of mtable() that you would like to use.

hth,
Z

> I'd like to obtain a table with the following structure (using standard 
> errors I already worked out how to archieve it):
>
>
> Variable & Coeff.   & robust S.E. & lower 95% KI & upper 95% KI \\
> Var1     & x.22^(*) & (xxxxx)     & [xxxxx       &  xxxxx]      \\
> .
> .
> .
>
>
>
> Maybe someone has any suggestions how to implement this kind of table?
>
> Best regards,
> Jan Henckens
>
>
> -- 
> jan.henckens | jöllenbecker str. 58 | 33613 bielefeld
> tel 0521-5251970
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


More information about the R-help mailing list