Reputation: 11
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")
Upvotes: 0
Views: 946
Reputation: 3677
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")
Upvotes: 1