0

I have a random effects model in which I model housing prices. Now I'd like to add a lag to the model using the plm package, however I don't know ho to do so. I coded my regression as follows:

 randomHUIS = plm(YHUIS ~ XHUIS, data = panel, index = c("Gemeente", "Jaartal"), model = "random")
 randomAPP = plm(YAPP ~ XAPP, data = panel, index = c("Gemeente", "Jaartal"), model = "random")           
Stibu
  • 15,166
  • 6
  • 57
  • 71
stuvu
  • 11
  • Your question does not contain a [reproducible example](http://stackoverflow.com/q/5963269/4303162). It is therefore hard to understand your problem and give you an appropriate answer. Please make your data available (e.g. by using `dput()`) or use one of the example data sets in R. Also, add the minimal code required to reproduce your problem to your post. – Stibu Mar 25 '16 at 18:49

1 Answers1

1

You could just do one of the following:

1) Put the lag function in the formula:

randomHUIS = plm(YHUIS ~ XHUIS + lag(your_variable_to_be_lagged), data = panel, index = c("Gemeente", "Jaartal"), model = "random")

2) lag the variable in your pdata.frame first (assuming your panel is already a pdata.frame), then put that (already) lagged variable in your formula:

panel$your_var_lag <- lag(panel$your_var) randomHUIS = plm(YHUIS ~ XHUIS + your_var_lag, data = panel, model = "random")

Helix123
  • 3,502
  • 2
  • 16
  • 36