Today I tried to estimate models using both plm and pgmm functions in the plm R package, with an interaction between X1 and lag(X2, 1). And I notice two issues.

Let $Y=b_1 X_1 + b_2 X_2 + b_3 X_1 X_2 + e$ be our model.

  1. When using plm, I got different results when I coded the interaction term with I(X1 * lag(X2, 1)) and when I just saved this multiplication X1 * lag(X2, 1) in a different variable of the dataset and then used it in the regression.

  2. With pgmm it is not even possible to run a formula which contains I(X1 * lag(X2, 1)). How can I pass such interaction?


1 Answer 1


Actually, the problem number 2 is easy to solve: instead of using I(X1 * lag(X2,1)), one should use X1:lag(X2,1). It works.

The issue number 1 remains, though. And also affects this solution for number 2. It means: results are different with one uses X1:lag(X2,1) whithin the formula or uses a new variable previouysly created with X1*lag(X2,1).

Any insights here would be very hepful.

  • 1
    $\begingroup$ If you calculate the variable beforehand on your own and put it into the data, make sure the data are alread a pdata.frame so that the lag function from package plm is executed and not stats::lag. plm::lag respects the panel structure of the data, stats::lag does not know about the panel structure. $\endgroup$
    – Helix123
    Jul 16, 2016 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.