2

I'm watching a video on YouTube about linear regression, one line of code is like this (function pgmm of package plm):

model1 = pgmm(democracy~lag(democracy)+lag(income)|lag(democracy, 2:99), DemocracyIncome25, index=c("country", "year"), model="twosteps", effect="twoways")

Just want to know what is the meaning of | here, and what does this operation really do.

Helix123
  • 3,502
  • 2
  • 16
  • 36

1 Answers1

2

In general the | represents the logical OR operator, but in the pgmm function the | sign is used to provide the instrumental variables that you want to use in your panel data GMM.

in your sample code model1 = pgmm(democracy~lag(democracy)+lag(income)|lag(democracy, 2:99), DemocracyIncome25, index=c("country", "year"), model="twosteps", effect="twoways") you have the dependent variable democracy and independent variables as lag of democracy and lagged income. The variables after the | lag(democracy, 2:99), DemocracyIncome25 will act as instrumental variables.

Please refer to the page 17 of the plm documentation here to the page 17 of the plm package documentation here

r2evans
  • 141,215
  • 6
  • 77
  • 149
Macosso
  • 1,352
  • 5
  • 22
  • 2
    Wrong on one account: `5==3|4` is *also* `TRUE`, but not (obviously) because 5 is equal to 3 or 4. What is happening is that `3|4` is reverting to the logical interpretation of numbers: if a number is zero then it is false, otherwise it is true. With that, `5==3|4` reduces to `5==TRUE`, which, by the same logic reduces to `TRUE==TRUE`. The rest of your answer is fine, but please update or remove that first paragraph and I'll change my downvote. – r2evans Sep 20 '21 at 12:59
  • 1
    I suggested an edit to your answer, hope it was not out of place. – r2evans Sep 20 '21 at 13:35
  • 2
    @r2evans, thanks for the updating the answer – Macosso Sep 20 '21 at 14:06
  • Thanks! I think I grasp the outline. There's another question though. What is the mathematical form of this formula: democracy~lag(democracy)+lag(income)|lag(democracy, 2:99)? I'm still not very clear what a role the instrumental variable plays in this model. – Laughingtree Sep 20 '21 at 14:12