rlagplm

What does lag(log(emp), 1:2) mean when using pgmm function?


I tried an example regarding pgmm function in plm package. The codes are as follows:

library(plm)
data("EmplUK", package = "plm")

## Arellano and Bond (1991), table 4 col. b 
z1 <- pgmm(log(emp) ~ lag(log(emp), 1:2) + lag(log(wage), 0:1)
           + log(capital) + lag(log(output), 0:1) | lag(log(emp), 2:99),
            data = EmplUK, effect = "twoways", model = "twosteps")
summary(z1, robust = FALSE)

I am not sure the meaning of lag(log(emp), 1:2) and also lag(log(emp), 2:99). Does lag(log(emp), 1:2) mean that from one unit to two unit lag value of log(emp) and lag(log(emp), 2:99) from two units to 99 units' lag value of log(emp)?

And also sometimes I got an error when running the regression in summary part but sometimes there was no such error (the codes are the same): Error in !class_ind : invalid argument type

Can anyone help me with these problems?That's the error here


Solution

  • log, a base R function, gives you the (natural) logarithm, in this case of variable emp.

    lag of package plm can be given a second argument, called k, like in your example. By looking at ?plm::lag.plm it becomes clear: k is

    an integer, the number of lags for the lag and lead methods (can also be negative). For the lag method, a positive (negative) k gives lagged (leading) values. For the lead method, a positive (negative) k gives leading (lagged) values, thus, lag(x, k = -1) yields the same as lead(x, k = 1). If k is an integer with length > 1 (k = c(k1, k2, ...)), a matrix with multiple lagged pseries is returned

    Thus, instead of typing lag twice to have the first and second lag:

    (lag(<your_variable>, 1) lag(<your_variable>, 2)

    one can simply type

    lag(<your_variable>, k = 1:2), or without the named argument

    lag(<your_variable>, 1:2).

    Setting k to 2:99 gives you the 2nd to 99th lags.

    The number refers to the number of time periods the lagging is applied to, not to the number of individuals (units) as the lagging is applied to all individuals.

    You may want to run the example in ?plm::lag.plm to aid understanding of that function.