title: Robust standard error (HC3) using vcovHC(), coeftest for plm object
body: <p>I want to estimate a fixed effect model and use a robust variance-covariance matrix with the HC3 small-sample adjustment.</p>
  
  <p>For the model itself I use following lines of code:</p>
  
  <pre><code>require(plm)
  require(sandwich)
  require(lmtest)
  require(car)
  QSFE &lt;- plm(log(SPREAD)~PERIOD, data = na.omit(QSREG), index = c("STOCKS", "TIME"), model = "within")
  </code></pre>
  
  <p>This works very fine, now to calculate the HC3 robust standard error, I use used the function <code>coeftest</code> with <code>vcovHC</code> in it. </p>
  
  <pre><code>coeftest(x = QSFE, vcov = vcovHC(QSFE, type = "HC3", method = "arellano"))
  </code></pre>
  
  <p>And this does not work. The returned error goes as follows: </p>
  
  <pre><code>Error in 1 - diaghat : non-numeric argument to binary operator
  </code></pre>
  
  <p>The issue is in vcovHC: when one sets the type to <code>"HC3"</code>. It uses the function <code>hatvalues()</code> to calculate <code>"diaghat"</code>, which does not support <code>plm</code> objects and returns the error: </p>
  
  <pre><code>Error in UseMethod("hatvalues") : 
  no applicable method for 'hatvalues' applied to an object of class "c('plm', 'panelmodel')"
  </code></pre>
  
  <p>Does anyone know, how to use the HC3 (HC2) estimator for plm. I think it should depend on the function hatvalues used in vcov, since HC0/HC1 works fine, because this do not need it.</p>