[R-sig-ME] pgmm errors in R
Vadym Ilchuk
v||chuk @end|ng |rom @@er|g@@edu
Sat Jan 23 18:23:08 CET 2021
Dear All,
I am a last-year student, currently working on my Bachelor's Thesis (so,
still learning R).
It has been a while I tried to find the solution to my problem, yet still
unsuccessfully. Thus, I decided to ask for help from people who know more
than me and potentially could suggest some solutions and ideas.
This is my main model:
[image: image.png]
Here is a dataset:
https://drive.google.com/file/d/1EDPnH2xRXZiPbUrD-sCUuIVdKUtWjojL/view?usp=sharing
So far I have created all the variables needed, and while *plm* works
perfectly, *pgmm *gives errors constantly.
This is my code (NB dataset already contains all the variables created),
furthermore, I tried to clean the needed variables from NAs, still, the
errors are present.
*******************************************************************************
#filtering dataset with NACE = A, and creating variables needed
LVData_A <- LVwin %>%
filter(NACE == 'A') %>%
filter(VAw > 0, FAw > 0, COGSw > 0, TURNw > 0, TFAw > 0) %>%
mutate(ID = ID,
Year = Year,
va = log(VAw),
tfa = log(TFAw),
fa = log(FAw),
cogs = log(COGSw),
turn = log(TURNw),
ta = log(TAw),
ff1 = ((LTD + LOAN)/TAw)/median((LTD + LOAN)/TAw, na.rm = TRUE),
ff2 = (CASHw/TAw)/median(CASHw/TAw, na.rm = TRUE),
ff3 = (INT/dplyr::lag(LTD + LOAN))/median(INT/lag(LTD + LOAN),
na.rm = TRUE),
ff4 = median(FAw)/SALEw,
ff5 = TFAw/TAw)
summary(LVData_A)
##########################################################################################################################
#Estimation of the TFP by using ACF method
LV_ACF_A <- prodest::prodestACF(LVData_A$turn, fX = LVData_A$cogs, sX =
LVData_A$tfa, pX = LVData_A$cogs, idvar = LVData_A$ID, timevar =
LVData_A$Year,
R = 100, cX = NULL, opt = 'DEoptim', theta0
= NULL, cluster = NULL)
summary(LV_ACF_A)
LVomegaACF_A <- prodest::omega(LV_ACF_A)
summary(LVomegaACF_A)
LVData_A$LVomegaACF_A <- prodest::omega(LV_ACF_A)
#########################################################################################################################
#Estimation of the TFP by using WRDG method
LV_WRDG_A <- prodest::prodestWRDG(LVData_A$turn, fX = LVData_A$cogs, sX =
LVData_A$tfa, pX = LVData_A$m, idvar = LVData_A$ID, timevar = LVData_A$Year,
cX = NULL)
summary(LV_WRDG_A)
LVomegaWRDG_A <- prodest::omega(LV_WRDG_A)
summary(LVomegaWRDG_A)
LVData_A$LVomegaWRDG_A <- as.xts(prodest::omega(LV_WRDG_A))
#########################################################################################################################
#Creating growth variables
LVData_A <- LVData_A %>%
arrange(ID, Year) %>%
group_by(ID) %>%
mutate(domegaACF_A = LVomegaACF_A - dplyr::lag(LVomegaACF_A),
#domegaWRDG_A = LVomegaWRDG_A - dplyr::lag(LVomegaWRDG_A),
debt = LTD + LOAN,
ddebt = debt - dplyr::lag(debt),
dsales = SALEw - dplyr::lag(SALEw)) %>%
ungroup
#Panel dataframe creation
PLVData_A <- pdata.frame(LVData_A, index = c("ID","Year"))
#GMM
z1 <- pgmm(domegaACF_A ~ plm::lag(domegaACF_A, 1) + ddebt + ff1 + log(Age)
+ ta + dsales | plm::lag(domegaACF_A, 2),
data = PLVData_A, effect = "twoways", model = "twosteps",
transformation = "d", index = c("ID", "Year"), collapse = FALSE, lost.ts =
NULL)
summary(z1, robust = TRUE)
# | plm::lag(domegaACF_A, 2:3)
z1 <- pgmm(domegaACF_A ~ plm::lag(domegaACF_A, 1) + ddebt + ff1 + log(Age)
+ ta + dsales | plm::lag(domegaACF_A, 2:3),
data = PLVData_A, effect = "twoways", model = "twosteps",
transformation = "d", index = c("ID", "Year"), collapse = FALSE, lost.ts =
NULL)
summary(z1, robust = TRUE)
# plm::lag(domegaACF_A, 1:2) AND plm::lag(domegaACF_A, 3)
z1 <- pgmm(domegaACF_A ~ plm::lag(domegaACF_A, 1:2) + ddebt + ff1 +
log(Age) + ta + dsales | plm::lag(domegaACF_A, 3),
data = PLVData_A, effect = "twoways", model = "twosteps",
transformation = "d", index = c("ID", "Year"), collapse = FALSE, lost.ts =
NULL)
summary(z1, robust = TRUE)
#| plm::lag(domegaACF_A, 1:2)
z1 <- pgmm(domegaACF_A ~ ddebt + ff1 + log(Age) + ta + dsales |
plm::lag(domegaACF_A, 1:2),
data = PLVData_A, effect = "twoways", model = "twosteps",
transformation = "d", index = c("ID", "Year"), collapse = FALSE, lost.ts =
NULL)
summary(z1, robust = TRUE)
# effect = "individual"
z1 <- pgmm(domegaACF_A ~ plm::lag(domegaACF_A, 1) + ddebt + ff1 + log(Age)
+ ta + dsales | plm::lag(domegaACF_A, 2:3),
data = PLVData_A, effect = "individual", model = "twosteps",
transformation = "ld", index = c("ID", "Year"), collapse = FALSE, lost.ts =
NULL)
summary(z1, robust = TRUE)
#effect = "twoways", model = "onestep", transformation = "d"
z1 <- pgmm(domegaACF_A ~ plm::lag(domegaACF_A, 1) + ddebt + ff1 + log(Age)
+ ta + dsales | plm::lag(domegaACF_A, 1),
data = PLVData_A, effect = "twoways", model = "onestep",
transformation = "d", index = c("ID", "Year"), collapse = FALSE, lost.ts =
NULL)
summary(z1, robust = TRUE)
#effect = "individual", model = "onestep", transformation = "ld"
z1 <- pgmm(domegaACF_A ~ plm::lag(domegaACF_A, 1) + ddebt + ff1 + log(Age)
+ ta + dsales | plm::lag(domegaACF_A, 1),
data = PLVData_A, effect = "individual", model = "onestep",
transformation = "ld", index = c("ID", "Year"), collapse = FALSE, lost.ts =
NULL)
summary(z1, robust = TRUE)
#
z1 <- pgmm(domegaACF_A ~ plm::lag(domegaACF_A, 1) | plm::lag(domegaACF_A,
2:3),
data = PLVData_A, effect = "twoways", model = "onestep",
transformation = "ld", index = c("ID", "Year"), collapse = FALSE, lost.ts =
NULL)
summary(z1, robust = TRUE)
#Check of the correlation
PLVData_A %>%
select(domegaACF_A, ddebt, ff1, Age, ta, dsales) %>%
cor(use = "complete.obs")
*******************************************************************************
Each GMM model specification yields different types of errors.
Thank you in advance for your devoted time.
Best,
Vadym
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 53849 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20210123/1f95f2a6/attachment-0001.png>
More information about the R-sig-mixed-models
mailing list