Stack Exchange
Extracting residual degrees of freedom from pgmm object
I'm having trouble extracting the number of degrees of freedom from a pgmm object. The command df.resudual() used to work just fine, but now it is not. Instead of returning a number, it returns the df.residual() function itself.
Here is a minimal example using the plm documentation:
data("EmplUK", package="plm")
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")
df.residual(emp.gmm)

> function (object, ...) 
> UseMethod("df.residual")
> <bytecode: 0x39a9370>
> <environment: namespace:stats>

I tried looking inside the pgmm command to figure out what is going on, and I think that the problem is in this line:
result <- list(coefficients = coefficients, residuals = residuals, 
           vcov = vcov, fitted.values = fitted.values, df.residual = df.residual, 
           model = yX, W = W, A1 = A1, A2 = A2, call = cl, args = args)

Because df.residual has not previously been defined, then the list entry df.residual = df.residual is just returning the global entry for the (generic) function.
Is this an error in the package? Or is there something else going on here? I was able to extract DoFs from pgmm objects before just fine.
PS. This got closed on Cross Validated.  Originally here: https://stats.stackexchange.com/questions/339239/extracting-residual-degrees-of-freedom-from-pgmm-object 

Can you specify when 'used to work fine' was (in terms of package version number)?

By the way, the source code of the development version on R-Forge contains this line # TODO: df.residual is not defined here, hence the function 'df.residual' is attached. Maybe contact the maintainer of the package and ask him to kindly takle this TODO.
