w12345678
w12345678

Reputation: 73

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

Upvotes: 0

Views: 1024

Answers (2)

Eugenio Palmieri
Eugenio Palmieri

Reputation: 1

I am not sure if it is just the lags, because

data("DemocracyIncome", package = "pder")
length(unique(DemocracyIncome$year))

[1] 11

and

data("DemocracyIncome25", package = "pder")
length(unique(DemocracyIncome25$year))
[1] 7

but in the examples

diff25 <- pgmm(democracỹ lag(democracy) + lag(income) |
lag(democracy, 2:99) + lag(income, 2:99),
DemocracyIncome25, model = "twosteps")

and

diff25coll <- pgmm(democracỹ lag(democracy) + lag(income) |
lag(democracy, 2:99)+ lag(income, 2:99),
DemocracyIncome, index=c("country", "year"),
model="twosteps", effect="twoways", subset = sample == 1,
collapse = TRUE)

they use 98 lags (2:99), which is much bigger than 7 and 11.

Upvotes: 0

Helix123
Helix123

Reputation: 3687

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.

Upvotes: 0

Related Questions