Unbalanced panel data in prodest package in R I have a question regarding the usage of unbalanced panel data for TFP estimation by using the prodest package.
The dataset could be found here: https://drive.google.com/file/d/1W5pva05hRiruo1AMNc62ln0GNtcVr5p6/view?usp=sharing
As you can see from the dataset, there are a lot of firms that have not reported some values in specific years, ending up with unbalanced panel data.
The code is the following. BUT in case I do not filter the data with &gt;0 values, I receive error messages coming from the estimation of TFP, saying that there are NaNs.
remove(list=ls())

library(plm)
library(dplyr)
library(ggplot2)
library(prodest)


pckg&lt;-c(&quot;plm&quot;,&quot;readxl&quot;,&quot;dplyr&quot;,&quot;ggplot2&quot;,&quot;prodest&quot;)
#install.packages(c(&quot;plm&quot;,&quot;readxl&quot;,&quot;dplyr&quot;,&quot;ggplot2&quot;,&quot;prodest&quot;))
lapply(pckg, require, character.only = TRUE)

# Set the working directory
setwd(&quot;C:/Users/vadya/Desktop/LT original currency&quot;)

# Downloading the survey data
Data &lt;- read.csv(&quot;LToc.csv&quot;, header=TRUE, sep=&quot;,&quot;)
str(Data)

Data$ID&lt;-as.numeric(as.factor(Data$ID))

summary(Data)

# Creating a panel data frame

DataA &lt;- Data %&gt;% 
  #filter(NACE == 'A') %&gt;% 
  #filter(TURN &gt; 0, TFA &gt; 0, FA &gt; 0, VA &gt; 0, L &gt; 0, M &gt; 0) %&gt;%
  mutate(ID = ID,
         Year = Year,
         turn = log(TURN),
         tfa = log(TFA),
         fa = log(FA),
         va = log(VA),
         cogs = log(COGS))
         #l = log(L),
         #m = log(M))
################################################################################################

mod2ACF &lt;-  prodest::prodestACF(DataA$va, fX = DataA$cogs, sX = DataA$tfa, pX = DataA$cogs, idvar = DataA$ID, timevar = DataA$Year, 
                                R = 100, cX = NULL, opt = 'optim', theta0 = NULL, cluster = NULL)  

mod2ACF
omegaACF &lt;- prodest::omega(mod2ACF)
summary(mod2ACF)
summary(omegaACF)


mod2W &lt;-  prodest::prodestWRDG(DataA$turn, fX = DataA$cogs, sX = DataA$tfa, pX = DataA$cogs, idvar = DataA$ID, timevar = DataA$Year, 
                               cX = NULL)  
mod2W
omegaW &lt;- prodest::omega(mod2W)
summary(mod2W)
summary(omegaW)

####################################################################################################################################

If I do not filter the dataframe, in the TFP estimation part (e.g., ACF method) I get the following error message.

Am I doing something wrong, and is there a way to make the prodest functions to work with unbalanced panel data?
Thanks in advance for the ideas! Would really much appreciate your concern!
A common technique we use in Python through Pandas is the introduction of means, medians and modes (depending on the structure of data) in the stead of these missing values.
Another great technique is introducing fitted values by a regression model, thus, predicting the missing values. In this case you'd want a command to drop your NaNs, estimate a model, and replace empty cells with their fitted value. Depending on your data's structure, you might encounter problems with this technique.
As a final comment, I'd suggest you use Python. Here's the pertinent website.