1
$\begingroup$

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: enter image description here

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: X is the control variables included in the code, and a and b are fixed effects

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

and I get the following message: enter image description here

$\endgroup$
13
  • $\begingroup$ This looks like dataset issue rather than code issue per se. Try if the code works with simulated data with longer T. My guess is it will and in this dataset you don’t have enough observations. Also you can get all info there is on pgmm by simply typing ?pgmm into console. Furthermore, it already has twoway fixed effects - that is what the option twoway does. If you want ‘vanilla’ fixed effects then just change argument ‘twoway’ to ‘individual’. $\endgroup$ – 1muflon1 Oct 13 '20 at 22:05
  • $\begingroup$ Tried not to restrict dataset to only 2011 and 2012 year, and got the following problem: Error: 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$ – Wadim iLchuk Oct 14 '20 at 9:19
  • $\begingroup$ but you are specifying lags for the instrument from 2-99. Last time I was giving you an answer with this dataset I just quickly checked the distribution of temporal dimension among panel IDs and if I remember correctly no ID had more than 9 years associated with it. Also you use lot of control variables and have non-trivial amount of missing observations and the panel is unbalanced I would not be surprised if there simply isn’t in the end enough data points to run the model you want. $\endgroup$ – 1muflon1 Oct 14 '20 at 9:44
  • $\begingroup$ But, even if I change the number from 99 to whatever 3,4,5,6... the problem is the same Error in Formula(formula) : inherits(object, "formula") is not TRUE. Also, If I try to use the same example as in pgmm function description with EmplUK dataset, the result is the same Error: n must be a nonnegative integer scalar, not an integer vector of length 2. Run rlang::last_error() to see where the error occurred. $\endgroup$ – Wadim iLchuk Oct 14 '20 at 9:47
  • $\begingroup$ then there might be some additional errors in the specification. However, I tried to run pgmm on a different panel dataset that is balanced and has long T worked fine for me and I tried to also use interaction terms so that is not the problem. As I originally recommended you should simulate a new dataset with long T. Keep the variable names and everything in the command same. See if it runs with simulated data. If it works with simul. data problem is not in command but with dataset. In that case double check all variables are properly declared and try running MVA and possibly imputation $\endgroup$ – 1muflon1 Oct 14 '20 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.