Skip to main content
Added links to source code and vignette file for the package.
Source Link
Pedro Cunha
  • 400
  • 3
  • 10
         ## Load data from plm package 
    
    if(!requireNamespace("plm", quietly = TRUE)){ 
    
     stop("Dataset from package \"plm\" needed for this example. 
         Please install the package.", call. = FALSE) 
    } 
    
    else{  
    
    data(EmplUK,
         package = "plm")  dat <- EmplUK  dat[,c(4:7)] <- log(dat[,c(4:7)])
         
         ## Arellano and Bond (1991) estimation in Table 4, column (a1) 
    
     m1 <- pdynmc(dat = dat, varname.i = "firm", varname.t = "year",
                  use.mc.diff = TRUE, use.mc.lev = FALSE, use.mc.nonlin = FALSE,
                  include.y = TRUE, varname.y = "emp", lagTerms.y = 2,
                  fur.con = TRUE, fur.con.diff = TRUE, fur.con.lev = FALSE,
                  varname.reg.fur = c("wage", "capital", "output"), lagTerms.reg.fur = c(1,2,2),
                  include.dum = TRUE, dum.diff = TRUE, dum.lev = FALSE, varname.dum = "year",
                  w.mat = "iid.err", std.err = "corrected", estimation = "onestep",
                  opt.meth = "none")
  summary(m1)
    }

While this is not a definitive answer, it's too long to post as a comment. Hope it helps anyway.

EDIT:

Source code

Vignette

         ## Load data from plm package 
    
    if(!requireNamespace("plm", quietly = TRUE)){ 
    
     stop("Dataset from package \"plm\" needed for this example. 
         Please install the package.", call. = FALSE) 
    } 
    
    else{  
    
    data(EmplUK,
         package = "plm")  dat <- EmplUK  dat[,c(4:7)] <- log(dat[,c(4:7)])
         
         ## Arellano and Bond (1991) estimation in Table 4, column (a1) 
    
     m1 <- pdynmc(dat = dat, varname.i = "firm", varname.t = "year",
                  use.mc.diff = TRUE, use.mc.lev = FALSE, use.mc.nonlin = FALSE,
                  include.y = TRUE, varname.y = "emp", lagTerms.y = 2,
                  fur.con = TRUE, fur.con.diff = TRUE, fur.con.lev = FALSE,
                  varname.reg.fur = c("wage", "capital", "output"), lagTerms.reg.fur = c(1,2,2),
                  include.dum = TRUE, dum.diff = TRUE, dum.lev = FALSE, varname.dum = "year",
                  w.mat = "iid.err", std.err = "corrected", estimation = "onestep",
                  opt.meth = "none")
  summary(m1)
    }

While this is not a definitive answer, it's too long to post as a comment. Hope it helps anyway.

## Load data from plm package 
    
    if(!requireNamespace("plm", quietly = TRUE)){ 
    
     stop("Dataset from package \"plm\" needed for this example. 
         Please install the package.", call. = FALSE) 
    } 
    
    else{  
    
    data(EmplUK,
         package = "plm")  dat <- EmplUK  dat[,c(4:7)] <- log(dat[,c(4:7)])
         
         ## Arellano and Bond (1991) estimation in Table 4, column (a1) 
    
     m1 <- pdynmc(dat = dat, varname.i = "firm", varname.t = "year",
                  use.mc.diff = TRUE, use.mc.lev = FALSE, use.mc.nonlin = FALSE,
                  include.y = TRUE, varname.y = "emp", lagTerms.y = 2,
                  fur.con = TRUE, fur.con.diff = TRUE, fur.con.lev = FALSE,
                  varname.reg.fur = c("wage", "capital", "output"), lagTerms.reg.fur = c(1,2,2),
                  include.dum = TRUE, dum.diff = TRUE, dum.lev = FALSE, varname.dum = "year",
                  w.mat = "iid.err", std.err = "corrected", estimation = "onestep",
                  opt.meth = "none")
  summary(m1)
    }

While this is not a definitive answer, it's too long to post as a comment. Hope it helps anyway.

EDIT:

Source code

Vignette

Source Link
Pedro Cunha
  • 400
  • 3
  • 10

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) && (length(unique(dat[, varname.t])) <
 3)){    

stop("Insufficient number of time periods to derive linear
     moment conditions.")  
}

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("plm", quietly = TRUE)){ 
    
     stop("Dataset from package \"plm\" needed for this example. 
         Please install the package.", call. = FALSE) 
    } 
    
    else{  
    
    data(EmplUK,
         package = "plm")  dat <- EmplUK  dat[,c(4:7)] <- log(dat[,c(4:7)])
         
         ## Arellano and Bond (1991) estimation in Table 4, column (a1) 
    
     m1 <- pdynmc(dat = dat, varname.i = "firm", varname.t = "year",
                  use.mc.diff = TRUE, use.mc.lev = FALSE, use.mc.nonlin = FALSE,
                  include.y = TRUE, varname.y = "emp", lagTerms.y = 2,
                  fur.con = TRUE, fur.con.diff = TRUE, fur.con.lev = FALSE,
                  varname.reg.fur = c("wage", "capital", "output"), lagTerms.reg.fur = c(1,2,2),
                  include.dum = TRUE, dum.diff = TRUE, dum.lev = FALSE, varname.dum = "year",
                  w.mat = "iid.err", std.err = "corrected", estimation = "onestep",
                  opt.meth = "none")
  summary(m1)
    }

which works just fine. Furthermore, if we run the following code:

length(unique(dat[, "year"]))

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[, "Year"]))

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.