# R: GMM Estimators in a dynamic panel [closed]

I put up a fixed effects regression using panel data with a time lag of the dependant variable, so somthing like this:

library(plm)
library(lmtest)
attach(data)
panel_data <- pdata.frame(data, index = c("country","time"))

model1 <- plm(Y~Y_l1+A+B+C, data = panel_data, model = "within",  effect = "twoway")


Where Y_l1 is the time lag of the dependant variable and A,B,C are other explanatory variables. I am using robust st. err. as well

robmodel <- coeftest(model1, vcov.=vcovHC(model1, method = c("arellano")))


My advisor now told me that as my number of time periods is rather small (its about 15) I should include GMM estimators for dynamic panels. He said it is fairly simple to include them in Stata, I however use R, therefore, I wanted to know if there is a simple way to include them in R as well? Is it possible to do it with one line of code?

## closed as off-topic by Peter Flom - Reinstate Monica♦Jul 13 at 13:26

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Peter Flom - Reinstate Monica
If this question can be reworded to fit the rules in the help center, please edit the question.

• Thanks, I am getting: error in terms.default(formula) : no terms component nor attribute do you know why that could be? – ArOk Oct 15 '18 at 14:56
• attach(data) panel_data <- pdata.frame(data, index = c("country","time"))  GMMmodel <- pgmm(A~lag(A_l1)+B,effect="twoways",model="twosteps") – ArOk Oct 15 '18 at 15:24
• Please, do not use dynformula as it is deprecated. Also, please use the package's vignette which is an updated version of the cited article. – Helix123 Oct 15 '18 at 21:09