title: R: HAC by NeweyWest using dynlm
body: <p>This is what I would like to do: </p>
  
  <pre><code>library("lmtest")
  library("dynlm")
  test$Date = as.Date(test$Date, format = "%d.%m.%Y")
  zooX = zoo(test[, -1], order.by = test$Date)
  f &lt;- d(Euribor3) ~ d(Ois3) + d(CDS) + d(Vstoxx) + d(log(omo)) + d(L(Euribor3))
  m1 &lt;- dynlm(f, data = zooX, start = as.Date("2005-01-05"),end = as.Date("2005-01-24"))
  m2 &lt;- dynlm(f, data = zooX, start = as.Date("2005-01-25"), end=as.Date("2005-02-14"))
  summary(m1)
  summary(m2)
  coeftest(m1, vcov=NeweyWest)
  coeftest(m2, vcov=NeweyWest)
  </code></pre>
  
  <p>There is no problem with the function <code>summary(m1)</code>
  However if I want to use HAC by NeweyWest i.e.<code>coeftest(m1, vcov=NeweyWest)</code>
  I get the following error message and I do not know why: <code>Error in na.fail.default(as.ts(x)) : missing values in object</code>
  What do I have to change on my code in order to get the result using <code>coeftest()</code>? Note: there are no missing values as you can see from the sample data. Many thanks!</p>
  
  <p>Sample Data:</p>
  
  <pre><code>    Date    Euribor3    Ois3    Vstoxx  CDS omo
  1   03.01.2005  2.154   2.089   14.47   17.938  344999
  2   04.01.2005  2.151   2.084   14.51   17.886  344999
  3   05.01.2005  2.151   2.087   14.42   17.950  333998
  4   06.01.2005  2.150   2.085   13.80   17.950  333998
  5   07.01.2005  2.146   2.086   13.57   17.913  333998
  6   10.01.2005  2.146   2.087   12.92   17.958  333998
  7   11.01.2005  2.146   2.089   13.68   17.962  333998
  8   12.01.2005  2.145   2.085   14.05   17.886  339999
  9   13.01.2005  2.144   2.084   13.64   17.568  339999
  10  14.01.2005  2.144   2.085   13.57   17.471  339999
  11  17.01.2005  2.143   2.085   13.20   17.365  339999
  12  18.01.2005  2.144   2.085   13.17   17.214  347999
  13  19.01.2005  2.143   2.086   13.63   17.143  354499
  14  20.01.2005  2.144   2.087   14.17   17.125  354499
  15  21.01.2005  2.143   2.087   13.96   17.193  354499
  16  24.01.2005  2.143   2.086   14.11   17.283  354499
  17  25.01.2005  2.144   2.086   13.63   17.083  354499
  18  26.01.2005  2.143   2.086   13.32   17.348  347999
  19  27.01.2005  2.144   2.085   12.46   17.295  352998
  20  28.01.2005  2.144   2.084   12.81   17.219  352998
  21  31.01.2005  2.142   2.084   12.72   17.143  352998
  22  01.02.2005  2.142   2.083   12.36   17.125  352998
  23  02.02.2005  2.141   2.083   12.25   17.000  357499
  24  03.02.2005  2.144   2.088   12.38   16.808  357499
  25  04.02.2005  2.142   2.084   11.60   16.817  357499
  26  07.02.2005  2.142   2.084   11.99   16.798  359999
  27  08.02.2005  2.141   2.083   11.92   16.804  355500
  28  09.02.2005  2.142   2.080   12.19   16.589  355500
  29  10.02.2005  2.140   2.080   12.04   16.500  355500
  30  11.02.2005  2.140   2.078   11.99   16.429  355500
  31  14.02.2005  2.139   2.078   12.52   16.042  355500
  </code></pre>
  
  <p><strong>Edit</strong>I think the problem is in this command: <code>zooX = zoo(test[, -1], order.by = test$Date)</code>, namely the function <code>order.by()</code>. If you delete this part, all else equal you can compute HAC by NeweyWest.( Of course you also need to change <code>start = as.Date("2005-01-25")</code>to the index number, e.g<code>start=50</code>.) But by deleting it you lose the start and end Date in the regression output, which was very useful. So if anyone knows a way around it, please let me know!</p>