<p>In order to get coefficient for the materials in the Levinsohn-Petrin model you need to set the gross option true.</p>
<pre><code> mod1LP = estprod::levinsohn_petrin(data = DataA, va ~ l | k | m, id = &quot;ID&quot;, time = &quot;Year&quot;, bootstrap = TRUE, gross = TRUE)
     summary(mod1LP)

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

Coefficients
   Estimate Std. Error z value  Pr(&gt;|z|)    
l 0.1033754  0.0067384  15.341 &lt; 2.2e-16 ***
k 0.5859219  0.0048667 120.394 &lt; 2.2e-16 ***
m 0.4808831  0.0143580  33.492 &lt; 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

#Bootstraped standard errors.
</code></pre>
<p>The other two functions unfortunately don't collect the coefficients for proxy variables.</p>
<p>An alternative is to find some different proxy and use <span class="math-container">$m$</span> as a control (I do not necessarily endorse such option from scientific perspective but if you are hell bent on having coefficient for <span class="math-container">$m$</span> its an option). In your dataset you don't have any additional variables beside <span class="math-container">$l$</span>, <span class="math-container">$k$</span> and <span class="math-container">$m$</span> (aside from COGS that is always N/A) so I will just create a new variable to show it would work:</p>
<pre><code> DataA<span class="math-container">$m2&lt;-(DataA$</span>m)^2

mod1OP = estprod::olley_pakes(data = DataA, va ~  l |  k | m2 |  m, id = &quot;ID&quot;, time = &quot;Year&quot;, bootstrap = TRUE, gross = TRUE)
 summary(mod1OP)
 
     
    Call
estprod::olley_pakes(data = DataA, formula = va ~ l | k | m2 | 
    m, id = &quot;ID&quot;, time = &quot;Year&quot;, bootstrap = TRUE, 
    gross = TRUE)

Coefficients
    Estimate Std. Error z value  Pr(&gt;|z|)    
l  0.1057613  0.0040007 26.4360 &lt; 2.2e-16 ***
k  0.4643984  0.0308697 15.0438 &lt; 2.2e-16 ***
m -0.0458770  0.0048684 -9.4234 &lt; 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

#Bootstraped standard errors.
 


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

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

Coefficients
   Estimate Std. Error t value  Pr(&gt;|t|)    
l 0.1210159  0.0075386  16.053 &lt; 2.2e-16 ***
k 0.4670722  0.0135809  34.392 &lt; 2.2e-16 ***
m 0.2595440  0.0158134  16.413 &lt; 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
</code></pre>
<p>Again such course of action does not seem to make sense to me but it gives you the desired output.</p>

CC BY-SA 4.0
2020-10-05T10:11:49.487Z
Hey, @1muflon1, thank you again for the clarification!
Wadim iLchuk
CC BY-SA 4.0
2020-10-05T11:44:36.960Z
My main concern was, how to calculate the TFP from the estprod package if it gives only 2 coefficients, while I need 3 of them?
Wadim iLchuk
CC BY-SA 4.0
2020-10-05T11:57:41.283Z
@WadimiLchuk if you care about net output and not gross output then you can just use the first 2 coefficients and turn the gross argument false then the functions estimate the net output
1muflon1
CC BY-SA 4.0
2020-10-04T20:27:03.243Z
2020-10-04T20:27:03.243Z
1muflon1
<p>I want to calculate the TFP by using the estprod function (I use R 4.0.2). As far as I understood the only way to calculate the TFP is manual following this logic <a href="https://i.sstatic.net/Km58I.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Km58I.png" alt="enter image description here" /></a>.
<code>omega_1 = (data$Y - data$Labor*coefs$statistic[1] - data$Capital*coefs$statistic[2] - data$Materials*coefs$statistic[3])</code> - this is basically the approach other author on StackExchange suggested to use in order to calculate the TFP. However, after running the regressions (LP, OP, Wooldridge) I get only 2 coefficients in the output, for capital and fo labor only, while for materials the coefficient is missing.</p>
<p>Would really much appreciate any comments and support, the dataset is available here:  <a href="https://drive.google.com/file/d/1aedWYABus1fQjKWxkOmYOmxv-qSja7hF/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1aedWYABus1fQjKWxkOmYOmxv-qSja7hF/view?usp=sharing</a></p>
<p>The code is the following so far:</p>
<pre><code>remove(list=ls())

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

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

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

Data<span class="math-container">$ID&lt;-as.numeric(as.factor(Data$</span>ID))

summary(Data)

# Creating a panel data frame
PData &lt;- pdata.frame(Data, index = c(&quot;ID&quot;,&quot;Year&quot;))

pdim(PData)
pvar(PData)

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

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

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

mod1W = estprod::wooldridge(data = DataA, va ~ l | k | m, id = &quot;ID&quot;, time = &quot;Year&quot;, bootstrap = TRUE, gross = FALSE)
summary(mod1W)
</code></pre>

<production-function><productivity><r>
TFP in R via estprod package
Wadim iLchuk
# TFP in R via estprod package

(Asked by: username_0 on 2020-10-04)

I want to calculate the TFP by using the estprod function (I use R 4.0.2). As far as I understood the only way to calculate the TFP is manual following this logic [![enter image description here](https://i.sstatic.net/Km58I.png)](https://i.sstatic.net/Km58I.png).
`omega_1 = (data$Y - data$Labor*coefs$statistic[1] - data$Capital*coefs$statistic[2] - data$Materials*coefs$statistic[3])` - this is basically the approach other author on StackExchange suggested to use in order to calculate the TFP. However, after running the regressions (LP, OP, Wooldridge) I get only 2 coefficients in the output, for capital and fo labor only, while for materials the coefficient is missing.

Would really much appreciate any comments and support, the dataset is available here: <https://drive.google.com/file/d/1aedWYABus1fQjKWxkOmYOmxv-qSja7hF/view?usp=sharing>

The code is the following so far:

```
remove(list=ls())

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

# Set the working directory
setwd("C:/Users/vadya/Desktop/baka")

# Downloading the survey data
Data <- read.csv("LV.csv", header=TRUE, sep=",")
str(Data)

Data$ID<-as.numeric(as.factor(Data$ID))

summary(Data)

# Creating a panel data frame
PData <- pdata.frame(Data, index = c("ID","Year"))

pdim(PData)
pvar(PData)

DataA <- Data %>% 
  filter(NACE == 'A') %>% 
  filter(VA > 0, L > 0, K > 0, M > 0) %>%
  select(ID, Year, L, VA, K, M) %>% 
  summarise(ID = ID,
            Year = Year,
            l = log(L),
            va = log(VA),
            k = log(K),
            m = log(M))

####################################################################################################################################
mod1LP = estprod::levinsohn_petrin(data = DataA, va ~ l | k | m, id = "ID", time = "Year", bootstrap = TRUE, gross = FALSE)
summary(mod1LP)

mod1OP = estprod::olley_pakes(data = DataA, va ~ l | k | m, id = "ID", time = "Year", bootstrap = TRUE, gross = FALSE)
summary(mod1OP)

mod1W = estprod::wooldridge(data = DataA, va ~ l | k | m, id = "ID", time = "Year", bootstrap = TRUE, gross = FALSE)
summary(mod1W)

```

**Tags:** production-function, productivity, r


---

## 1 answers

### Answer by username_1 on 2020-10-04. Score: 1 | Accepted answer

In order to get coefficient for the materials in the Levinsohn-Petrin model you need to set the gross option true.

```
 mod1LP = estprod::levinsohn_petrin(data = DataA, va ~ l | k | m, id = "ID", time = "Year", bootstrap = TRUE, gross = TRUE)
     summary(mod1LP)

    Call
estprod::levinsohn_petrin(data = DataA, formula = va ~ l | k | 
    m, gross = TRUE, id = "ID", time = "Year", bootstrap = TRUE)

Coefficients
   Estimate Std. Error z value  Pr(>|z|)    
l 0.1033754  0.0067384  15.341 < 2.2e-16 ***
k 0.5859219  0.0048667 120.394 < 2.2e-16 ***
m 0.4808831  0.0143580  33.492 < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

#Bootstraped standard errors.

```

The other two functions unfortunately don't collect the coefficients for proxy variables.

An alternative is to find some different proxy and use $m$ as a control (I do not necessarily endorse such option from scientific perspective but if you are hell bent on having coefficient for $m$ its an option). In your dataset you don't have any additional variables beside $l$, $k$ and $m$ (aside from COGS that is always N/A) so I will just create a new variable to show it would work:

```
 DataA$m2<-(DataA$m)^2

mod1OP = estprod::olley_pakes(data = DataA, va ~  l |  k | m2 |  m, id = "ID", time = "Year", bootstrap = TRUE, gross = TRUE)
 summary(mod1OP)
 
     
    Call
estprod::olley_pakes(data = DataA, formula = va ~ l | k | m2 | 
    m, id = "ID", time = "Year", bootstrap = TRUE, 
    gross = TRUE)

Coefficients
    Estimate Std. Error z value  Pr(>|z|)    
l  0.1057613  0.0040007 26.4360 < 2.2e-16 ***
k  0.4643984  0.0308697 15.0438 < 2.2e-16 ***
m -0.0458770  0.0048684 -9.4234 < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

#Bootstraped standard errors.
 

   mod1W = estprod::wooldridge(data = DataA, va ~ l | k | m2 | m, id = "ID", time = "Year", bootstrap = FALSE, gross = TRUE)
     summary(mod1W)

Call
estprod::wooldridge(data = DataA, formula = va ~ l | k | m2 | 
    m, gross = TRUE, id = "ID", time = "Year", bootstrap = FALSE)

Coefficients
   Estimate Std. Error t value  Pr(>|t|)    
l 0.1210159  0.0075386  16.053 < 2.2e-16 ***
k 0.4670722  0.0135809  34.392 < 2.2e-16 ***
m 0.2595440  0.0158134  16.413 < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

```

Again such course of action does not seem to make sense to me but it gives you the desired output.

> **Comments:**
> **username_0**: Hey, @username_1, thank you again for the clarification!  
> **username_0**: My main concern was, how to calculate the TFP from the estprod package if it gives only 2 coefficients, while I need 3 of them?  
> **username_1**: @username_0 if you care about net output and not gross output then you can just use the first 2 coefficients and turn the gross argument false then the functions estimate the net output  

---

