title: R: Robust SE's and model diagnostics in stargazer table
body: <p>I try to put some 2SLS regression outputs generated via <code>ivreg()</code> from the AER  package into a Latex document using the stargazer package. I have a couple of problems however that I can't seem to solve myself.</p>
  <ol>
  <li>I can't figure out on how to insert model diagnostics as provided by the summary of <code>ivreg()</code>. Namely weak instruments tests, Wu-Hausmann and Sargan Test. I would like to have them with the statistics usually reported underneath the table like number of observations, R-squared, and Resid. SE. The stargazer function doesn't seem to have an argument where you can provide a list with additional diagnostics. I didn't put this into my example because I honestly have no clue where to begin.</li>
  <li>I want to exchange the normal standard errors with robust standard errors and the only way to do this that i found is producing objects with robust standard errors and adding them in the <code>stargazer()</code> function with <code>se=list()</code>. I put this into the minimum working example below. Is there maybe a more elegant way to code this or maybe re-estimate the model and save it with robust standard errors?</li>
  </ol>
  <pre><code>library(AER)
  library(stargazer)
  
  y &lt;- rnorm(100, 5, 10)
  x &lt;- rnorm(100, 3, 15)
  z &lt;- rnorm(100, 3, 7)
  a &lt;- rnorm(100, 1, 7)
  b &lt;- rnorm(100, 3, 5)
  
  # Fitting IV models
  fit1 &lt;- ivreg(y ~ x + a  |
               a + z,
               model = TRUE)
  fit2 &lt;- ivreg(y ~ x + a  |
               a + b + z,
               model = TRUE)
  
  # Here are the se's and the diagnostics i want
  summary(fit1, vcov = sandwich, diagnostics=T)
  summary(fit2, vcov = sandwich, diagnostics=T)
  
  # Getting robust se's, i think HC0 is the standard
  # used with &quot;vcov=sandwich&quot; from the  above summary
  cov1        &lt;- vcovHC(fit1, type = &quot;HC0&quot;)
  robust1     &lt;- sqrt(diag(cov1))
  cov2        &lt;- vcovHC(fit2, type = &quot;HC0&quot;)
  robust2     &lt;- sqrt(diag(cov1))
  
  # Create latex table
  stargazer(fit1, fit2, type = &quot;latex&quot;, se=list(robust1, robust2))
  </code></pre>