I am trying to create a table of regressions using the Stargazer package in R. I have several regressions that differ only in the dummy variables. I want it to report the coefficient of the independent variable, the constant, etc., and to say "yes" or "no" if certain fixed effects (i.e., dummy variables) were included in the regression. These are my regressions:
m1 <- lm(data=merge1,log(total_units)~log(priceIndex))
m2 <- lm(data=merge1,log(total_units)~log(priceIndex)+factor(fips_state_code))
m3 <- lm(data=merge1,log(total_units)~log(priceIndex)+factor(fips_state_code)+factor(month))
m4 <- lm(data=merge1,log(total_units)~log(priceIndex)+factor(fips_state_code)+factor(month)+factor(year))
m5 <- lm(data=merge1,log(total_units)~log(priceIndex)+factor(fips_state_code)+factor(month)+time*factor(fips_state_code))
m6 <- lm(data=merge1,log(total_units)~log(priceIndex)+factor(fips_state_code)+factor(month)+factor(year)+time*factor(fips_state_code))
I've tried several variations of the stargazer command to get the table to look right, but it never does. When I run this command, for each of the five or six regressions, it works as I expect it to:
stargazer(m2,type="text",
omit = c("fips_state_code","month","year","time"),
omit.labels = c("State FE?","Month of year FE?","Year FE?","State time trend?"))
I.e., for m2, it says "Yes" next to "State FE?" and "No" next to all the other questions. For m3, it says "Yes" next to "State FE?" and "Month of year FE?" and "No" next to the other questions.
But when I run this command, the table reports "No" for all of the questions for all of the regressions:
stargazer(m1,m2,m3,m4,m5,m6,type="text",
omit = c("fips_state_code","month","year","time"),
omit.labels = c("State FE?","Month of year FE?","Year FE?","Time FE?"))
Does anybody know what is going on? It should work the same whether I do each regression separately or together, no?
I get other weird outcomes too... When I run the following:
stargazer(m3,m4,m5,m6,type="html",
omit = c("fips_state_code","month","year","time"),
omit.labels = c("State FE?","Month of year FE?","Year FE?","State time trend?"))
I get this:
<table style="text-align:center"><tr><td colspan="5" style="border-bottom: 1px solid black"></td></tr><tr><td style="text-align:left"></td><td colspan="4"><em>Dependent variable:</em></td></tr>
<tr><td></td><td colspan="4" style="border-bottom: 1px solid black"></td></tr>
<tr><td style="text-align:left"></td><td colspan="4">log(total_units)</td></tr>
<tr><td style="text-align:left"></td><td>(1)</td><td>(2)</td><td>(3)</td><td>(4)</td></tr>
<tr><td colspan="5" style="border-bottom: 1px solid black"></td></tr><tr><td style="text-align:left">log(priceIndex)</td><td>2.962<sup>***</sup></td><td>-0.746<sup>***</sup></td><td>0.142</td><td>-1.947<sup>***</sup></td></tr>
<tr><td style="text-align:left"></td><td>(0.206)</td><td>(0.249)</td><td>(0.224)</td><td>(0.276)</td></tr>
<tr><td style="text-align:left"></td><td></td><td></td><td></td><td></td></tr>
<tr><td style="text-align:left">Constant</td><td>-0.094</td><td>11.248<sup>***</sup></td><td>8.570<sup>***</sup></td><td>15.030<sup>***</sup></td></tr>
<tr><td style="text-align:left"></td><td>(0.652)</td><td>(0.779)</td><td>(0.709)</td><td>(0.868)</td></tr>
<tr><td style="text-align:left"></td><td></td><td></td><td></td><td></td></tr>
<tr><td colspan="5" style="border-bottom: 1px solid black"></td></tr><tr><td style="text-align:left">State FE?</td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td></tr>
<tr><td style="text-align:left">Month of year FE?</td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td></tr>
<tr><td style="text-align:left">Year FE?</td><td>No</td><td>No</td><td>No</td><td>No</td></tr>
<tr><td style="text-align:left">State time trend?</td><td>No</td><td>No</td><td>No</td><td>No</td></tr>
<tr><td colspan="5" style="border-bottom: 1px solid black"></td></tr><tr><td style="text-align:left">Observations</td><td>2,853</td><td>2,853</td><td>2,853</td><td>2,853</td></tr>
<tr><td style="text-align:left">R<sup>2</sup></td><td>0.968</td><td>0.974</td><td>0.984</td><td>0.985</td></tr>
<tr><td style="text-align:left">Adjusted R<sup>2</sup></td><td>0.967</td><td>0.974</td><td>0.983</td><td>0.984</td></tr>
<tr><td style="text-align:left">Residual Std. Error</td><td>0.340 (df = 2806)</td><td>0.305 (df = 2800)</td><td>0.244 (df = 2771)</td><td>0.235 (df = 2766)</td></tr>
<tr><td style="text-align:left">F Statistic</td><td>1,830.438<sup>***</sup> (df = 46; 2806)</td><td>2,019.427<sup>***</sup> (df = 52; 2800)</td><td>2,041.885<sup>***</sup> (df = 81; 2771)</td><td>2,084.570<sup>***</sup> (df = 86; 2766)</td></tr>
<tr><td colspan="5" style="border-bottom: 1px solid black"></td></tr><tr><td style="text-align:left"><em>Note:</em></td><td colspan="4" style="text-align:right"><sup>*</sup>p<0.1; <sup>**</sup>p<0.05; <sup>***</sup>p<0.01</td></tr>
</table>