2

I am trying to automate the process by which I output the coefficients and standard errors from a number of regression models into a single table for output via xtable as html.

Some similar questions (like this one) have been directed to a function called "outreg" by Paul Johnson, but the page no longer exists and I can't find the code.

Others (like this one) use solutions that seem to give me errors because my models do not all have the same number of variables.

To clarify my task ...

  • I have n polr (ordinal logistic) models from which I want to output the coefficients and standard errors.
  • Each model includes a different number of predictors.
  • I need one data.frame (?) with a column or two for each model and a row for each predictor
  • it's not critical how the standard errors are output in relation to the coefficients

each model has output like this with successively more predictors:

>summary(model1)["coefficients"]
$coefficients

                Value Std. Error  t value
relGPA          0.8683499 0.04185389 20.74717
mcAvgGPA        1.3885515 0.09688030 14.33265
Deny|Waitlist   0.5707912 0.01553476 36.74283
Waitlist|Accept 0.8398921 0.01618358 51.89779
Community
  • 1
  • 1
Sam Swift
  • 913
  • 1
  • 11
  • 17
  • 2
    I imagine this will be applicable here: http://stats.stackexchange.com/questions/6856/aggregating-results-from-linear-model-runs-r – Chase Mar 22 '11 at 23:25
  • Excellent, thank you Chase! The graph suggestions on the question are pretty awesome, but the mtable{memisc} solution is exactly what I was hoping to find. – Sam Swift Mar 23 '11 at 16:49
  • The outreg function is still available on PJ's website: http://pj.freefaculty.org/stat/ps706/ – ATMathew Mar 23 '11 at 17:59
  • Thanks ATMathew, I looked around his site quite a bit, but hadn't found that folder. Good to have it linked from here because none of the other threads that mention it have the updated link. – Sam Swift Mar 23 '11 at 18:18
  • 1
    Possible duplicate of [Printing regression coefficients from multiple models to a shared data frame](http://stackoverflow.com/questions/29685806/printing-regression-coefficients-from-multiple-models-to-a-shared-data-frame) – rafa.pereira May 07 '17 at 18:18

1 Answers1

3

You can cut and paste from here.

FWIW, I have tinkered with his outreg.R to add some features (t-stats, multipage, etc), but it's only on my work computer, so I'll post tomorrow.


Update

Here's my tweaked version, but like the original, it still requires a list of lm or glm objects. It seems too long to cut&paste, so this is a link to my dropbox.com public folder.

Richard Herron
  • 9,760
  • 12
  • 69
  • 116
  • thanks richardh, I'd love to take a look at your tinkered version because I'm not having luck with the code in the PDF. I'm getting errors about the use of "$" somewhere in the function. I think it may have to do with my models being polr(). Or I may have introduced an error transferring from the pdf. – Sam Swift Mar 23 '11 at 16:15
  • I'm not familiar with `polr()`, but `outreg.R` requires an `lm` or `glm` object. – Richard Herron Mar 23 '11 at 18:42
  • Thanks for contributing your version of outreg. I'll mark this as answered since it is a good solution for people not doing ordinal logistic models. For others that are, the mtable function in memsic is working great. – Sam Swift Mar 23 '11 at 20:32
  • The DropBox link no longer works and the linked document has errors and seems very dated. I think this might be a good example of why code for the solution should actually be contained in the solution, not linked. This is a good question but I recommend that the solution be deleted so that a more up to date solution can be provided. – Hack-R Sep 09 '14 at 19:53
  • @Hack-R -- Yes, I mentioned that the file is too long to cut and paste into the SO text field. Your best bet now is the `stargazer` package. A lot changes in 3.5 years. :) – Richard Herron Sep 09 '14 at 23:05