TFP estimation in R by using prodest and estprod packages I am writing my Bachelor Thesis and I really need help with the TFP estimation. so far I have a dataset with log values of Value added (va), Labour (l), Capital (k), and Materials (m). The initial dataset is available here:
https://drive.google.com/file/d/1aedWYABus1fQjKWxkOmYOmxv-qSja7hF/view?usp=sharing
So far my code is:
remove(list=ls())

library(plm)
library(dplyr)
library(ggplot2)
library(prodest)
library(estprod)
library(broom)

setwd(&quot;C:/Users/vadya/Desktop/baka&quot;)


Data &lt;- read.csv(&quot;LV.csv&quot;, header=TRUE, sep=&quot;,&quot;)
str(Data)

summary(Data)

DataA &lt;- Data %&gt;% 
  filter(NACE == 'A') %&gt;% 
  filter(VA &gt; 0, L &gt; 0, K &gt; 0, M &gt; 0) %&gt;%
  mutate(l = log(L),
         va = log(VA),
         k = log(K),
         m = log(M))

wooldridge(data = DataA, va ~ l | k | m, id = &quot;ID&quot;, time = &quot;Year&quot;, bootstrap = TRUE, gross = FALSE)


levinsohn_petrin(data = DataA, va ~ l | k | m, id = &quot;ID&quot;, time = &quot;Year&quot;, bootstrap = TRUE, gross = FALSE)


olley_pakes(data = DataA, va ~ l | k | m, id = &quot;ID&quot;, time = &quot;Year&quot;, bootstrap = TRUE, gross = FALSE)

mod1 = estprod::levinsohn_petrin(data = DataA,
                                 formula = va ~ l | k | m, 
                                 id = &quot;ID&quot;, 
                                 time = &quot;Year&quot;, 
                                 reps = 20,
                                 gross = FALSE) 
mod1
  
mod2 = prodest::prodestLP(DataA$va,
                      fX = DataA$l,
                          sX = DataA$k, 
                      pX = DataA$m,
                          idvar = DataA$ID,
                      timevar = DataA$Year,
                          opt='optim',
                          exit = FALSE,
                          tol = 1e-100)  

omega = prodest::omega(mod2) 

So far, the problem is the following - with estprod package I get only coefficients estimated for l and k, without m

With prodest package, the problem is the following:

A saw the same discussion in another theme on StackExchange where a guy was asking the same question, but he had provided some part of his data, and everything worked. But in my case the problems are different.
Does anyone faced the same problem, and is it possible to solve these issues, since I only have begun studying TFP in R, so I would really appreciate your help and any impact provided. Thanks in advance!!!
You get the error because your ID is string and the prodestLP function has a problem with that here - leading to incorrectly specifying that replacement matrix in this case.
You can solve this issue with:
 DataA$ID&lt;-as.numeric(as.factor( DataA$ID))

once you declare the ID as numeric the code works:
     mod2 = prodest::prodestLP(DataA$va,
+                            fX = DataA$l,
+                            sX = DataA$k, 
+                            pX = DataA$m,
+                            idvar = DataA$ID,
+                            timevar = DataA$Year,
+                            opt='optim',
+                            exit = FALSE,
+                            tol = 1e-100)  
&gt;  
&gt;  omega = prodest::omega(mod2) 

with output:
    summary(mod2)

-------------------------------------------------------------
-               Production Function Estimation              -
-------------------------------------------------------------
                   Method :    LP              
-------------------------------------------------------------
                               fX1       sX1 
Estimated Parameters      :   0.107     0.458 
                             (0.012)   (0.052)
-------------------------------------------------------------
N                         :  4397
-------------------------------------------------------------
Bootstrap repetitions     :  20
1st Stage Parameters      :  0.107     0.249 
Optimizer                 :  optim
-------------------------------------------------------------
Elapsed Time              :  0.02 mins

-------------------------------------------------------------


summary(omega)
       V1        
 Min.   :-3.452  
 1st Qu.: 1.428  
 Median : 1.842  
 Mean   : 1.778  
 3rd Qu.: 2.202  
 Max.   : 4.492  


Update these are the packages I am running and code before the one shown above (also I am running R  version 4.0.2 (2020-06-22)):
rm(list = ls())

Data &lt;- read.csv(&quot;~/R studio/excercises in randomness/tfp2/Gmail/LV.csv&quot;)

 View(Data)
 
 
 

 pckg&lt;-c(&quot;plm&quot;,&quot;readxl&quot;,&quot;dplyr&quot;,&quot;ggplot2&quot;, &quot;broom&quot;,&quot;prodest&quot;, &quot;estprod&quot;)
 #install.packages(c(&quot;plm&quot;,&quot;readxl&quot;,&quot;dplyr&quot;,&quot;ggplot2&quot;, &quot;broom&quot;,&quot;prodest&quot;, &quot;estprod&quot;))
 lapply(pckg, require, character.only = TRUE)
 
 head(Data)
 
 summary(Data)
 
 DataA &lt;- Data %&gt;% 
         filter(NACE == 'A') %&gt;% 
         filter(VA &gt; 0, L &gt; 0, K &gt; 0, M &gt; 0) %&gt;%
         mutate(l = log(L),
                va = log(VA),
                k = log(K),
                m = log(M))