I have the following problem with the Arellano and Bond (1991) or Blundell and Bond (1998) estimators in R using the plm package. I receive the following problem when trying to run the needed regression:
The dataset could be found here: https://drive.google.com/file/d/1WUCrMCi7bJmhYbzZxNuXDpFIwXJTqdh3/view?usp=sharing
My code is the following, it seems that I do everything correctly, the formula I need to be estimated is the following:
remove(list=ls())
library(plm)
library(dplyr)
library(ggplot2)
library(prodest)
library(estprod)
library(broom)
library(pdynmc)
pckg<-c("plm","readxl","dplyr","ggplot2", "broom","prodest", "estprod")
#install.packages(c("plm","readxl","dplyr","ggplot2", "broom","prodest", "estprod"))
lapply(pckg, require, character.only = TRUE)
# Set the working directory
setwd("C:/Users/vadya/Desktop/baka")
# Downloading the survey data
Data <- read.csv("test.csv", header=TRUE, sep=",")
str(Data)
Data$ID<-as.numeric(as.factor(Data$ID))
summary(Data)
DataA11 <- Data %>%
filter(NACE == 'A' & Year < 2013) %>%
filter(VA > 0, L > 0, FA > 0, M > 0, Turn > 0, TA > 0) %>%
mutate(ID = ID,
Year = Year,
l = log(L),
va = log(VA),
fa = log(FA),
m = log(M),
turn = log(Turn),
ta = log(TA),
ff1 = (LTD + STD)/TA,
ff2 = lag(Cash),
ff4 = FA/Sales,
ff5 = TFA/TA)
####################################################################################
mod2LP <- prodest::prodestLP(DataA11$turn, fX = DataA11$l, sX = DataA11$fa, pX = DataA11$m, idvar = DataA11$ID, timevar = DataA11$Year,
R = 100, cX = NULL, opt = "optim", theta0 = NULL, cluster = NULL, tol = 1e-100, exit = FALSE)
mod2LP
omegaLP <- prodest::omega(mod2LP)
summary(mod2LP)
summary(omegaLP)
DataA11$omega <- prodest::omega(mod2LP)
######################################################################################
DataA11 <- DataA11 %>%
arrange(ID, Year) %>%
group_by(ID) %>%
mutate(domega = omega - dplyr::lag(omega),
debt = LTD + STD,
ddebt = debt - dplyr::lag(debt),
dsales = Sales - dplyr::lag(Sales)) %>%
ungroup
PDataA11 <- pdata.frame(DataA11, index = c("ID","Year"))
pdim(PData)
pvar(PData)
z1 <- pgmm(domega ~ lag(domega, 1:2) + ddebt + ff1 + ff1:ddebt + Age + ta + dsales | lag(domega, 2:99),
data = PDataA11, effect = "twoways", model = "twosteps")
summary(z1, robust = TRUE)
ALSO! It would be perfect if you provide any information on that package and also what I do incorrectly + would be great if you said how to add fixed effects to this pgmm function.
Thanks a lot to each of you in advance!!!:)
UPDATE:
data("EmplUK", package = "plm")
## Arellano and Bond (1991), table 4 col. b
emp.gmm <- 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(emp.gmm)
I run this code, that is provided here: https://rdrr.io/cran/plm/man/pgmm.html
n
must be a nonnegative integer scalar, not an integer vector of length 2. Then I filtered to get only the positive numbers (which is not logical) and got the next issue: Error in Formula(formula) : inherits(object, "formula") is not TRUE. So, I do not really know how to solve it, despite the fact I have read the documentation of the package. $\endgroup$