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'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
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. >
I always use apsrtable in the apsrtable package, which allows you to specify a vcov matrix using the "se" option. The only trick is that you have to append it to your model object, something like this: fit=lm(y ~ x) fit$se=vcovHC(fit) apsrtable(fit, se="robust") Andrew Miles On Jan 5, 2011, at 7:57 PM, 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'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.
Reasonably Related Threads
- Problems producing quantreg-Tables
- Package/command for creating a table of panel models ?
- Calculation of BIC done by leaps-package
- package to do inverse probability weighting in longitudinal data
- latex output of regressions with standardized regression coefficients and t-statistics based on Huber-White