<p>for my Master Thesis I want to regress the ESG score on the stock price drop during the pandemic. For OLS this works fine. To check for potential Endogeneity I also conduct a 2SLS regression with the industry average ESG score as instrument. This works fine as long as I leave out the industry dummies. When adding them I get the following error Message:</p>
<p>Warning message:</p>
<p>In pf(w, df[1L], df[2L], lower.tail = FALSE) : NaNs produced</p>
<p>Moreover, the diagnostics for weak instruments and Wu-Hausman also show NaN.</p>
<p>I am aware of the dummy variable trap so not all industries were included.</p>
<p>Does anyone know why I get this error message? Any help is appreciated. Below I will provide my results with and without dummies.</p>
<p>Without dummies:</p>
<p><a href="https://i.sstatic.net/ff7E3.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ff7E3.png" alt="enter image description here" /></a></p>
<p>With dummies:</p>
<p><a href="https://i.sstatic.net/BYlqA.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/BYlqA.png" alt="enter image description here" /></a></p>
<p>Thank you!</p>
<p>As mentioned in the comments I sould provide the minimum working example. I managed to replicate the warning message with the first 10 rows of my data:</p>
<p>structure(list(NAME = c(&quot;A-MARK PRECIOUS METALS&quot;, &quot;AAON&quot;, &quot;AAR&quot;,
&quot;ABBOTT LABORATORIES&quot;, &quot;ABBVIE&quot;, &quot;ABEONA THERAPEUTICS&quot;, &quot;ABERCROMBIE &amp; FITCH A&quot;,
&quot;ABIOMED&quot;, &quot;ABM INDS.&quot;, &quot;ABRAXAS PETROLEUM&quot;), ESG = c(30.93,
46.31, 24.66, 70.67, 79.79, 36.58, 69.13, 25.88, 72.66, 18.88
), LogAssets = c(13.538484837701, 13.0147959839376, 14.5473975668402,
18.0628622893116, 18.8299054426017, 11.9263455151269, 15.0139386185708,
13.9751825387466, 15.1444141253049, 11.9688365085588), Quick = c(0.38,
2.27, 1.69, 1.14, 0.6, 2.26, 1.24, 4, 1.32, 0.1), I_Agri = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0), I_Cons = c(0, 0, 0, 0, 0, 0, 0, 0,
0, 0), I_Fin = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), I_Man = c(0,
1, 0, 1, 1, 1, 0, 1, 0, 0), I_Mining = c(0, 0, 0, 0, 0, 0, 0,
0, 0, 1), I_Serv = c(0, 0, 0, 0, 0, 0, 0, 0, 1, 0), I_Trade = c(1,
0, 0, 0, 0, 0, 1, 0, 0, 0), I_Utility = c(0, 0, 1, 0, 0, 0, 0,
0, 0, 0), Drop = c(0.107419712070875, 0.277738886944347, 0.791427308882015,
0.297000895255148, 0.31485022307202, 0.75, 0.527002967359051,
0.222692078618225, 0.473209685729006, 0.683189655172414), Leverage = c(0.8177,
0.0178, 0.3993, 0.3623, 0.8679, 0.0169, 0.2659, 0, 0.3257, 1.5458
), ROA = c(0.0622, 0.1926, 0.0065, 0.0726, 0.0542, -0.4324, -0.0259,
0.1888, 0.0095, -0.6467), ESG_A = c(41.9334803921569, 41.6947268673356,
42.0122772277228, 41.6947268673356, 41.6947268673356, 41.6947268673356,
41.9334803921569, 41.6947268673356, 37.5789174311926, 34.9968604651163
)), row.names = c(NA, -10L), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;
))</p>
<p>The code I used:</p>
<p>library(AER)</p>
<p>IV2=ivreg(Drop~ESG+LogAssets+Leverage+ROA+Quick+I_Cons+I_Fin+I_Man+I_Mining+I_Serv+I_Trade+I_Utility | ESG_A+LogAssets+Leverage+ROA+Quick+I_Cons+I_Fin+I_Man+I_Mining+I_Serv+I_Trade+I_Utility, data=mwe)</p>
<p>summary(IV2, diagnostics = TRUE)</p>
<p>Rstudio Version: 2022.2.0.443
Operating system: Windows 10 pro 64 bit</p>

CC BY-SA 4.0
2022-06-01T21:12:26.930Z
Can you please share your minimal working example? Otherwise we can only guess what’s wrong
1muflon1
CC BY-SA 4.0
2022-06-02T21:21:22.797Z
@1muflon1 Thank you for your answer, as you can see I am new to R and programming in general. I provided the 10 first rows of my data and some addintional info. Hope that helps!
Hirschbraten22
<econometrics><instrumental-variable>
Adding industry dummies to 2SLS in R
Hirschbraten22
# Adding industry dummies to 2SLS in R

(Asked by: username_0 on 2022-06-01)

for my Master Thesis I want to regress the ESG score on the stock price drop during the pandemic. For OLS this works fine. To check for potential Endogeneity I also conduct a 2SLS regression with the industry average ESG score as instrument. This works fine as long as I leave out the industry dummies. When adding them I get the following error Message:

Warning message:

In pf(w, df[1L], df[2L], lower.tail = FALSE) : NaNs produced

Moreover, the diagnostics for weak instruments and Wu-Hausman also show NaN.

I am aware of the dummy variable trap so not all industries were included.

Does anyone know why I get this error message? Any help is appreciated. Below I will provide my results with and without dummies.

Without dummies:

[![enter image description here](https://i.sstatic.net/ff7E3.png)](https://i.sstatic.net/ff7E3.png)

With dummies:

[![enter image description here](https://i.sstatic.net/BYlqA.png)](https://i.sstatic.net/BYlqA.png)

Thank you!

As mentioned in the comments I sould provide the minimum working example. I managed to replicate the warning message with the first 10 rows of my data:

structure(list(NAME = c("A-MARK PRECIOUS METALS", "AAON", "AAR",
"ABBOTT LABORATORIES", "ABBVIE", "ABEONA THERAPEUTICS", "ABERCROMBIE & FITCH A",
"ABIOMED", "ABM INDS.", "ABRAXAS PETROLEUM"), ESG = c(30.93,
46.31, 24.66, 70.67, 79.79, 36.58, 69.13, 25.88, 72.66, 18.88
), LogAssets = c(13.538484837701, 13.0147959839376, 14.5473975668402,
18.0628622893116, 18.8299054426017, 11.9263455151269, 15.0139386185708,
13.9751825387466, 15.1444141253049, 11.9688365085588), Quick = c(0.38,
2.27, 1.69, 1.14, 0.6, 2.26, 1.24, 4, 1.32, 0.1), I\_Agri = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0), I\_Cons = c(0, 0, 0, 0, 0, 0, 0, 0,
0, 0), I\_Fin = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), I\_Man = c(0,
1, 0, 1, 1, 1, 0, 1, 0, 0), I\_Mining = c(0, 0, 0, 0, 0, 0, 0,
0, 0, 1), I\_Serv = c(0, 0, 0, 0, 0, 0, 0, 0, 1, 0), I\_Trade = c(1,
0, 0, 0, 0, 0, 1, 0, 0, 0), I\_Utility = c(0, 0, 1, 0, 0, 0, 0,
0, 0, 0), Drop = c(0.107419712070875, 0.277738886944347, 0.791427308882015,
0.297000895255148, 0.31485022307202, 0.75, 0.527002967359051,
0.222692078618225, 0.473209685729006, 0.683189655172414), Leverage = c(0.8177,
0.0178, 0.3993, 0.3623, 0.8679, 0.0169, 0.2659, 0, 0.3257, 1.5458
), ROA = c(0.0622, 0.1926, 0.0065, 0.0726, 0.0542, -0.4324, -0.0259,
0.1888, 0.0095, -0.6467), ESG\_A = c(41.9334803921569, 41.6947268673356,
42.0122772277228, 41.6947268673356, 41.6947268673356, 41.6947268673356,
41.9334803921569, 41.6947268673356, 37.5789174311926, 34.9968604651163
)), row.names = c(NA, -10L), class = c("tbl\_df", "tbl", "data.frame"
))

The code I used:

library(AER)

IV2=ivreg(Drop~ESG+LogAssets+Leverage+ROA+Quick+I\_Cons+I\_Fin+I\_Man+I\_Mining+I\_Serv+I\_Trade+I\_Utility | ESG\_A+LogAssets+Leverage+ROA+Quick+I\_Cons+I\_Fin+I\_Man+I\_Mining+I\_Serv+I\_Trade+I\_Utility, data=mwe)

summary(IV2, diagnostics = TRUE)

Rstudio Version: 2022.2.0.443
Operating system: Windows 10 pro 64 bit

**Tags:** econometrics, instrumental-variable
> **Comments:**
> **username_1**: Can you please share your minimal working example? Otherwise we can only guess what’s wrong  
> **username_0**: @1muflon1 Thank you for your answer, as you can see I am new to R and programming in general. I provided the 10 first rows of my data and some addintional info. Hope that helps!  

---

## 0 answers

