title: ADL(2,2) modelling in R with differenced variables and lags
body: <p>I'm new to time series analysis and I am trying to model this relationship based on a very simple dataset containing only two time series: percentual changes of sales - <strong>y</strong>, regressed on the percentual change in purchases - <strong>x</strong> and a deterministic trend. </p>
  
  <pre><code>'data.frame':   98 obs. of  3 variables:
   $ time         : int  1 2 3 4 5 6 7 8 9 10 ...
   $ sales        : num  3.18 4.59 5.41 5.68 4.62 ...
   $ comppurchases: num  1.675 0.246 0.333 0.969 0.147 ...
  </code></pre>
  
  <p>The dataset is based on an example from a book, so I am trying to figure out the regression formula according to the output presented in the book. The author presented coefficients for y_(t-1), ∆y_t-1, x_t, ∆x_t, ∆x_t-1 and time as explanatory variables.</p>
  
  <p>This would then be my equation:</p>
  
  <blockquote>
    <p>∆y_t = a + φ<em>y_(t-1) + λ</em>∆y_t-1 + β<em>x_t + β1</em>∆x_t + β2*∆x_t-1 + + d*time + error</p>
  </blockquote>
  
  <p>And the corresponding R syntax:</p>
  
  <p><code>regr &lt;- dynlm(d(sales) ~ L(sales,1)+L(d(sales))+ comppurchases +d(comppurchases)+L(d(comppurchases)) + time, data=df)</code></p>
  
  <p>The problem is, whenever I run the syntax, I get this error:</p>
  
  <blockquote>
    <p>Error: all(sapply(args, function(x) is.zoo(x) || !is.plain(x) ||
    (is.plain(x) &amp;&amp;  .... is not TRUE</p>
  </blockquote>
  
  <p>Is there anything wrong with my syntax? What am I missing here? I'm not even sure if the problem is with the syntax or with my understanding of the regression formula. </p>
  
  <p>Thanks in advance!</p>