ycroissant / plm

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

Fixef Function with Instruments #10

Closed gorkembostanci closed 3 years ago

gorkembostanci commented 3 years ago

Hello,

The fixef function gives the following error when instruments are used in plm function:

Error in tcrossprod(coef(object), as.matrix(object$model[, -1, drop = FALSE])) : non-conformable arguments

I believe this is because the object 'as.matrix(object$model[, -1, drop = FALSE])' has the instruments in it. I think this wasn't an issue before March.

Best,

tappek commented 3 years ago

Thank your for reporting. This bug is in since 2.4-0 when fixef was fixed for two-way FE models. You can workaround this by estimating a one-way model with dummies for the other dimension.

gorkembostanci commented 3 years ago

I see, thank you!

tappek commented 3 years ago

This is fixed in the development version since a few days in rev. 1293, https://r-forge.r-project.org/R/?group_id=406, the root cause being a different one than supposed in the original report.

Install the development version via install.packages("plm", repos="http://R-Forge.R-project.org").

Be sure to check out the fast mode of the package by setting options("plm.fast" = TRUE).

[While fixing this bug, I found an issue in package fixest:fixef() related to this (https://github.com/lrberge/fixest/issues/190) and found a somewhat suprisingly dynamic setting of the reference level in lfe:getfe() (https://github.com/sgaure/lfe/issues/52).]

tappek commented 2 years ago

plm version 2.4-2 now on CRAN (2021-09-21) containing this fix