3
$\begingroup$

I am attempting to perform an unbalanced panel data regression in R. My code is as follows:

pdata <- plm.data(b2, index = c("ticker", "year"))
try1 <- plm(formula = logDipLoanTotal ~ PrimeFiling  + 
logLiabBefore + logSalesBefore + EmplBefore + DebttoAssetRatio + 
squareDebttoAssetRatio + FSCashShortTermInvestments + Percent + 
NUM_OF_EMPLOYEES, data = pdata, model = "within", effect = "time")
summary(try1)

I run into the following error:

duplicate couples (id-time) in resulting pdata.frame
to find out which, use e.g. table(index(your_pdataframe), useNA = "ifany")
duplicate couples (id-time)

This is obvious - I am having issues because my panel data is unbalanced, where the ticker/year combination can be associated with multiple lines of data. This is because multiple "deals" were done in the year associated with the company ticker in the year, or sometimes no deals were run in the ticker/year combination. How do I run this kind of model in RStudio with unbalanced data? Let me know if this doesn't make sense and I can edit the question.

$\endgroup$
0
$\begingroup$

It would be helpful to provide a reproductible example. In the paper Panel Data Econometrics in R: The plm Package, the authors explicitly mention that economic panel datasets often happen to be unbalanced, which case needs some adaptation to the methods. Hopefully, they provide a solution and the result of their work is bundled in the plm add-on package.

The following example is from Arellano and Bond (1991). Employment is explained by past values of employment (two lags), current and first lag of wages and output and current value of capital.

R> emp.gmm <- pgmm(dynformula(emp ~ wage + capital + output, lag = list(2, + 1, 0, 1),
                  log = TRUE), EmplUK, effect = "twoways", model = "twosteps", 
                 + gmm.inst = ~log(emp), lag.gmm = list(c(2, 99))) 
R> summary(emp.gmm)

Call: Unbalanced Panel: n=140, T=7-9, N=1031

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.