Working with statistical model results in R often means that the user has to learn about the class of the model to further manipulate it. A few packages can help with that.
Model results are complex data structures that often vary a lot depending on the package and underlying model procedure that produced them.
Since learning about each model object class can be initially highly instructive but then quickly bothersome, some R packages have been developed to enable users to quickly convert model results into more manipulable and/or printable objects.
This note presents some of these packages.
My small contribution to the package includes tidiers for the exponential random graph models produced by the
There are still a lot of different things that a package like
broom could try to achieve. Out of this list of ideas by Ben Bolker, the feature that I would find most useful is a ‘tidy’ method for marginal effects and conditional probabilities: see below.
margins package is a port of the Stata
marginsplot commands, which produce numerical estimates and plots of marginal effects from model results. The logic of the package is very well presented in its introductory vignette.
prediction package is the logical complement to
margins, and is written by the same author. In similar fashion to the
broom package, the
prediction package brings more “tidy” logic to model results by wrapping around the output of many, many
predict functions, in order to always return a (tidy) data frame.
Details on the
prediction package are not yet available as a vignette, but the
README file of its GitHub repository is explicit enough.
My sole contribution to the package has consisted in adding support for displaying the residual standard error of linear models, which is usually the only goodness of fit statistic that I care about.
If you are familiar with Stata, you are almost certainly familiar with the
outreg2 packages, which perform similar operations. The
leanout package, in particular, embeds a very convincing logic that trims down regression results to their bare essentials (i.e. t-values instead of p-values) and privileges the root mean squared error (the residual standard error) over the “R-squared.” In R, some of the same logic is embedded in the
This note was heavily updated on July 2, 2016 and April 19, 2017.
: this blog post by Joseph Rickert contains links to several recent R packages that help to manipulate various model results—see the
- First published on September 17th, 2015