title: Need to implement a recursive and rolling estimate scheme on a model
body: <p>As part of a homework assignment, we are asked the following question:</p>
  
  <blockquote>
    <p>Using the same data set as in Exercise 3 and for house price growth, run several regression models with one, two, three, and four lags of price growth in the right‐ hand side of the model. Analyze the regression results. Choose your favorite model and implement a recursive and a rolling estimation scheme. Plot the time series of the estimates of the regression coefficients and observe how much they change over time.</p>
  </blockquote>
  
  <p>I can't seem to get this to work in R. This is my Code so far:</p>
  
  <pre><code>PRQ &lt;- read_excel("~/Desktop/144/HW2/Chapter4_exercises_data.xls",sheet = "Exercise 3")
  
  price_ts&lt;-ts(PRQ$P,start = 1980:2, freq=4)
  
  r_price &lt;- diff(log(price_ts)) ##growth rate
  
  lag&lt;-append(NA, r_price[-length(r_price)])
  
  lag2&lt;-append(NA, lag[-length(lag)])
  
  lag3&lt;-append(NA,lag2[-length(lag2)])
  
  lag4&lt;-append(NA, lag3[-length(lag3)])
  
  y1&lt;-lm(r_price~lag)
  
  y2&lt;-lm(r_price~lag+lag2)
  
  y3&lt;-lm(r_price~lag+lag2+lag3)
  
  y4&lt;-lm(r_price~lag+lag2+lag3+lag4)
  
  summary(y1)
  
  summary(y2)
  
  summary(y3)
  
  summary(y4)
  </code></pre>
  
  <hr>
  
  <p>In case my question is unclear, this is the <a href="https://i.stack.imgur.com/rjnbT.png" rel="nofollow noreferrer">textbook description</a> of what I need to do. Any help is appreciated!</p>