pdynmc package in R | GMM issue I am a student, currently working on my Bachelor's Thesis. And as the next deadline approaches, I hope someone could give me a hand on my constant issue:
I need to estimate the next model with GMM estimator:

So far I was using pgmm function in plm package. You can check other topics of mine with the issues I have faced, and I still did not solve them.
Hence, I tried to move to another package pdynmc authorized by Dr. Markus Fritsch.
Here is a part of my dataset filtered with firms having at least 5 years of observations: https://drive.google.com/file/d/1dFUgXp8e1K0CdqMTpbtfviDq9vgJNOxW/view?usp=sharing
I am not sure you can get a context of it, but I need to estimate similar to this model as:
A change or growth in the dependent variable from t to t+1 (ΔTFPt+1) = GMM instruments, as far as I understood, of the, lagged dependent variable (so lagged change in the dependent variable) (ΔTFPt, and ΔTFPt-1) + change in one other variable (ΔDebt), the measure of needed variable (financial friction) + interaction between last 2 variables (financial friction * ΔDebt) + control variables (firm age, firm size or log(TA), change in sales or ΔSales).
In my dataset, needed variables are:

ID - is an ID of the companies
Year - the year of observation
ta - log of total assets
ff1-5 - financial friction variable of the companies
LVomegaACF_A - is a TFP measure
domegaACF_A - is ΔTFP measure
ddebt -  ΔDebt variable
dsales -  ΔSales variable
Age - age of the companies

I tried to use the package as follows:
model &lt;- pdynmc(dat = LVcheck, varname.i = &quot;ID&quot;, varname.t = &quot;Year&quot;,
                varname.y = &quot;domegaACF_A&quot;, lagTerms.y = 2,
                fur.con = FALSE, varname.reg.fur = c(&quot;ddebt&quot;, &quot;ff1&quot;, &quot;Age&quot;, &quot;ta&quot;, &quot;dsales&quot;),
                lagTerms.reg.fur = c(1,1,1,1,1),
                fur.con.diff = TRUE, fur.con.lev = FALSE,
                include.dum = TRUE, dum.diff = TRUE, dum.lev = FALSE, varname.dum = &quot;Year&quot;,
                w.mat = &quot;iid.err&quot;, std.err = &quot;corrected&quot;, estimation = &quot;onestep&quot;, opt.meth = &quot;none&quot;,
                use.mc.nonlin = FALSE, use.mc.diff = TRUE, use.mc.lev = FALSE, include.y = TRUE)

And the error I receive:
Error in pdynmc(dat = LVData_A, varname.i = &quot;ID&quot;, varname.t = &quot;Year&quot;,  :
  Insufficient number of time periods to derive linear moment conditions.

The question is the following, why the number of periods is insufficient if the only firms are displayed that have at least 5 years of observations?
And also, is my code written accordingly to my model specification, and all the arguments needed are written correctly.
I would really much appreciate your responses and any support from your side. Here is the package description https://rdrr.io/cran/pdynmc/man/pdynmc.html
Despite the fact, everything is quite detailed there, I still do not understand what is wrong with what I am doing.
Thank you very much in advance.
I apologize for my previous comment; it doesn't make much sense.
Upon inspecting your data, I've found that there are IDs for which you only have observations for two years. The problematic IDs are: 9231, 24873, 24907, 78341, 78998, 90246, 92673, 92787, and 93846. You can see the full frequency table here.
By looking at the source code for the package, we can see what causes that error message to appear:
  if((use.mc.diff | use.mc.lev) &amp;&amp; (length(unique(dat[, varname.t])) &lt;
 3)){    

stop(&quot;Insufficient number of time periods to derive linear
     moment conditions.&quot;)  
}

which I understand as: if the length of the vector containing the unique dates is less than 3, then the estimation cannot be computed.
Looking at the package help, we can run the example code provided:
## Load data from plm package 
    
    if(!requireNamespace(&quot;plm&quot;, quietly = TRUE)){ 
    
     stop(&quot;Dataset from package \&quot;plm\&quot; needed for this example. 
         Please install the package.&quot;, call. = FALSE) 
    } 
    
    else{  
    
    data(EmplUK,
         package = &quot;plm&quot;)  dat &lt;- EmplUK  dat[,c(4:7)] &lt;- log(dat[,c(4:7)])
         
         ## Arellano and Bond (1991) estimation in Table 4, column (a1) 
    
     m1 &lt;- pdynmc(dat = dat, varname.i = &quot;firm&quot;, varname.t = &quot;year&quot;,
                  use.mc.diff = TRUE, use.mc.lev = FALSE, use.mc.nonlin = FALSE,
                  include.y = TRUE, varname.y = &quot;emp&quot;, lagTerms.y = 2,
                  fur.con = TRUE, fur.con.diff = TRUE, fur.con.lev = FALSE,
                  varname.reg.fur = c(&quot;wage&quot;, &quot;capital&quot;, &quot;output&quot;), lagTerms.reg.fur = c(1,2,2),
                  include.dum = TRUE, dum.diff = TRUE, dum.lev = FALSE, varname.dum = &quot;year&quot;,
                  w.mat = &quot;iid.err&quot;, std.err = &quot;corrected&quot;, estimation = &quot;onestep&quot;,
                  opt.meth = &quot;none&quot;)
  summary(m1)
    }

which works just fine. Furthermore, if we run the following code:
length(unique(dat[, &quot;year&quot;]))

we get 9 as the output, which is clearly greater than 3. However, if we do the same using the data you have provided:
length(unique(datacheck[, &quot;Year&quot;]))

the result is 1, which is smaller than 3, just as the error message pointed out.
I can't figure out why that is happening. My guess is that perhaps you need at least 3 unique sequences of years or something else, because you do have enough observations with more than 3 years available.
While this is not a definitive answer, it's too long to post as a comment. Hope it helps anyway.
EDIT:
Source code
Vignette