ycroissant / plm

Panel Data Econometrics with R
GNU General Public License v2.0
49 stars 13 forks source link

problem with summary.pgmm #23

Closed calebepiacentini closed 2 years ago

calebepiacentini commented 2 years ago

When trying to summarise results from a pgmm object there is the following error message: Error in t(y) %*% x : non-conformable arguments

Same problem is reported at: https://stackoverflow.com/questions/10138633/pgmm-from-plm-package-gives-error-for-summary

It only happens when T<5. The problem seems to be that summary is calculating the mtest() autocorrelation test function for orders T=1 and T=2, which is not possible whenever T=3 and T=4 (since it does both, it is only possible to get a summary for T>=5).

Solution provided in the link results in yet another error: Error in printCoefmat(x$coefficients, digits = digits) : 'x' must be coefficient matrix/data frame Which problably is due to the coefficients attribute of a pgmm object being a list, resulting in error in the the function printCoefmat(). However, including some kind of if statement in the summary function for pgmm may solve the issue.

tappek commented 2 years ago

Thank you for pointing to this! The author of the answer on stackoverflow did not adjust print.summary.pgmm to cater for the modified summary.pgmm and I think that is where you get the second error from.

The development version now contains an adjustment for this (and in the same vain for mtest to error gracefully in case the order is larger than or equal to available observations).

You can install the development version via

# install.packages("remotes") # remove '#' if pkg 'remotes' is not installed
remotes::install_github("ycroissant/plm")