Code: LaTeX tables for lme4 models

I have recently discovered memisc, an extremely useful R package by Martin Elff (see his memisc page here). The package contains any number of useful functions, and is particularly good at helping one manage and recode survey data. However, by far my favorite thing about the package is the mtable() function. mtable() makes it easy to compare the results from different models from within R and, along with toLatex(), makes it easy create $$\text{\LaTeX{}}$$ tables. Unfortunately, the functions that parse lme4 model objects is out-dated. The code below updates them for the current release version of lme4. A couple things to note, however: first, these functions do not work with model objects created by lme4a, which are significantly different than those produced in lme4; and second, the getSummary.mer() function currently only reports the results from two-level models, though extending it shouldn’t be too difficult.

This entry was posted in Code, LaTeX, R. Bookmark the permalink.

4 Responses to Code: LaTeX tables for lme4 models

1. John says:

Great blog – very helpful! I hadn’t seen the memisc package before.

On this topic – since you’ve IV’s at one of your categories, I thought I’d ask: do you know if there’s a way to get tsls (using the sem package) estimates from R to work with the memisc package?

• Jason says:

Hello John, sorry for the delay in responding.

I actually haven’t tried to get memisc and sem to play together. I don’t do much with sem, so never thought to spend the time. It shouldn’t be too hard to implement basic support, though.

2. Christoph says:

Hi

First of all, thank you for the script. I do have a quick question about your calculation of the p-values. I was trying to debug why I was getting strange output tables on my results and was wondering if I am making a mistake.

As you calculate it, the normal does not take the absolute value of the t-value , and therefore gives you strange results when the initial model produces negative t-values.

In particular I mean this part:

p <- (1 – pnorm(smry@coefs[, 3])) * 2

Am I missing something?

Thank you,
Christoph

• Christoph says:

Ah nevermind. I just saw that you updated the code in the full package.

Thank you again, this function saved A LOT of time for me.