title: Lagged Regression
body: <p>So I am a beginner to R but I am running some code which simulates 100 observations of a y variable that follows the formula y_t=1+.5*y(<em>t-1)+u. I then want to run a regression of y on y</em>(t-1) and y_(t-2) and a constant.  When I run the regression using the dyn package it shows the coefficient on y_(t-2) as NA.  Anyone have any thoughts on this? </p>
  
  <p>Here is my code: </p>
  
  <pre><code>y&lt;-numeric(100)
  for (i in 2:100){
  u &lt;- rnorm(1, mean= 0, sd = 1)
  y[1]&lt;-2
  y[i]&lt;-1+.5*y[i-1]+u
  }
  
  model&lt;-dyn$lm(y ~ lag(y, -1)+lag(y,-2))
  </code></pre>
  
  <p>Here is the result: </p>
  
  <pre><code>Call:
  lm(formula = dyn(y ~ lag(y, -1) + lag(y, -2)))
  
  
  **Coefficients: (1 not defined because of singularities)**
  
  
  Residual standard error: 2.147e-16 on 98 degrees of freedom
  Multiple R-squared: 1, Adjusted R-squared: 1 
  F-statistic: 2.344e+33 on 1 and 98 DF,  p-value: &lt; 2.2e-16
  </code></pre>