~/code/R/

Stargazer options

Cheatsheets. html

  • ``

Summary Stats

Table

Display Summary Stats

year month day delay temp wind precip quarter hot
2013 1 1 17.483553 36.81909 13.233970 0 1 FALSE
2013 1 2 25.322674 28.70000 10.884461 0 1 FALSE
2013 1 3 8.450451 29.57750 8.582901 0 1 FALSE
2013 1 4 12.103858 34.33250 14.001157 0 1 FALSE
2013 1 5 5.696203 36.56000 9.398037 0 1 FALSE
2013 1 6 12.383333 39.92000 9.110342 0 1 FALSE
Statistic N Mean St. Dev. Min Pctl(25) Pctl(75) Max
year 364 2,013.000 0.000 2,013 2,013 2,013 2,013
month 364 6.511 3.445 1 4 9.2 12
day 364 15.679 8.784 1 8 23 31
delay 364 15.080 13.883 -1.349 5.446 20.007 97.771
temp 364 55.531 17.598 15.455 40.114 71.647 91.085
wind 364 9.464 4.398 2.637 6.797 11.508 56.388
precip 364 0.121 0.335 0 0 0.03 4
hot 364 0.022 0.147 0 0 0 1
Statistic N Pctl(75) St. Dev.
year 364 2,013 0.000
month 364 9.2 3.445
day 364 23 8.784
delay 364 20.007 13.883
temp 364 71.647 17.598
wind 364 11.508 4.398
precip 364 0.03 0.335
hot 364 0 0.147
Statistic year month day delay temp wind precip hot
N 364 364 364 364 364 364 364 364
Mean 2,013.000 6.511 15.679 15.080 55.531 9.464 0.121 0.022
St. Dev. 0.000 3.445 8.784 13.883 17.598 4.398 0.335 0.147
Min 2,013 1 1 -1.349 15.455 2.637 0 0
Pctl(25) 2,013 4 8 5.446 40.114 6.797 0 0
Pctl(75) 2,013 9.2 23 20.007 71.647 11.508 0.03 0
Max 2,013 12 31 97.771 91.085 56.388 4 1

Regressions

Model

# 
# Call:
# lm(formula = delay ~ temp + wind + precip, data = both)
# 
# Residuals:
#     Min      1Q  Median      3Q     Max 
# -47.164  -8.150  -3.148   4.667  70.493 
# 
# Coefficients:
#             Estimate Std. Error t value Pr(>|t|)    
# (Intercept)  6.15166    2.98897   2.058   0.0403 *  
# temp         0.07905    0.03933   2.010   0.0452 *  
# wind         0.28523    0.15741   1.812   0.0708 .  
# precip      15.25495    2.01280   7.579 2.98e-13 ***
# ---
# Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# 
# Residual standard error: 12.82 on 360 degrees of freedom
# Multiple R-squared:  0.1541,  Adjusted R-squared:  0.147 
# F-statistic: 21.86 on 3 and 360 DF,  p-value: 5.003e-13

Display Regression Results

Dependent variable:
delay
(1) (2)
temp 0.079** 0.164**
(0.039) (0.066)
wind 0.285* 0.237
(0.157) (0.157)
precip 15.255*** 14.845***
(2.013) (2.004)
quarter2 -2.060
(2.579)
quarter3 -6.755**
(3.121)
quarter4 -4.408**
(2.037)
Constant 6.152** 5.246
(2.989) (3.412)
Observations 364 364
R2 0.154 0.175
Adjusted R2 0.147 0.161
Residual Std. Error 12.822 (df = 360) 12.718 (df = 357)
F Statistic 21.860*** (df = 3; 360) 12.593*** (df = 6; 357)
Note: p<0.1; p<0.05; p<0.01

Regressions - Options

Change style

delay
(1) (2)
temp 0.079** 0.164**
(0.039) (0.066)
wind 0.285* 0.237
(0.157) (0.157)
precip 15.255*** 14.845***
(2.013) (2.004)
quarter2 -2.060
(2.579)
quarter3 -6.755**
(3.121)
quarter4 -4.408**
(2.037)
Constant 6.152** 5.246
(2.989) (3.412)
N 364 364
R2 0.154 0.175
Adjusted R2 0.147 0.161
Residual Std. Error 12.822 (df = 360) 12.718 (df = 357)
F Statistic 21.860*** (df = 3; 360) 12.593*** (df = 6; 357)
Notes: ***Significant at the 1 percent level.
**Significant at the 5 percent level.
*Significant at the 10 percent level.

Label columns, dep.var, covariate

These are awesome results!
A better caption
Flight delay (in minutes)
(1) (2)
Temperature 0.079** 0.164**
(0.039) (0.066)
Wind speed 0.285* 0.237
(0.157) (0.157)
Rain (inches) 15.255*** 14.845***
(2.013) (2.004)
2nd quarter -2.060
(2.579)
3rd quarter -6.755**
(3.121)
Fourth quarter -4.408**
(2.037)
Constant 6.152** 5.246
(2.989) (3.412)
Observations 364 364
R2 0.154 0.175
Adjusted R2 0.147 0.161
Residual Std. Error 12.822 (df = 360) 12.718 (df = 357)
F Statistic 21.860*** (df = 3; 360) 12.593*** (df = 6; 357)
Note: p<0.1; p<0.05; p<0.01

Change the column.labels

Dependent variable:
delay
Good Better
(1) (2)
temp 0.079** 0.164**
(0.039) (0.066)
wind 0.285* 0.237
(0.157) (0.157)
precip 15.255*** 14.845***
(2.013) (2.004)
quarter2 -2.060
(2.579)
quarter3 -6.755**
(3.121)
quarter4 -4.408**
(2.037)
Constant 6.152** 5.246
(2.989) (3.412)
Observations 364 364
R2 0.154 0.175
Adjusted R2 0.147 0.161
Residual Std. Error 12.822 (df = 360) 12.718 (df = 357)
F Statistic 21.860*** (df = 3; 360) 12.593*** (df = 6; 357)
Note: p<0.1; p<0.05; p<0.01

Column Separator

Dependent variable:
delay
Good Better
(1) (2) (3) (4)
temp 0.079** 0.079** 0.164** 0.164**
(0.039) (0.039) (0.066) (0.066)
wind 0.285* 0.285* 0.237 0.237
(0.157) (0.157) (0.157) (0.157)
precip 15.255*** 15.255*** 14.845*** 14.845***
(2.013) (2.013) (2.004) (2.004)
quarter2 -2.060 -2.060
(2.579) (2.579)
quarter3 -6.755** -6.755**
(3.121) (3.121)
quarter4 -4.408** -4.408**
(2.037) (2.037)
Constant 6.152** 6.152** 5.246 5.246
(2.989) (2.989) (3.412) (3.412)
Observations 364 364 364 364
R2 0.154 0.154 0.175 0.175
Adjusted R2 0.147 0.147 0.161 0.161
Residual Std. Error 12.822 (df = 360) 12.822 (df = 360) 12.718 (df = 357) 12.718 (df = 357)
F Statistic 21.860*** (df = 3; 360) 21.860*** (df = 3; 360) 12.593*** (df = 6; 357) 12.593*** (df = 6; 357)
Note: p<0.1; p<0.05; p<0.01

Report t-statistics

Dependent variable:
delay
(1) (2)
temp 0.079 0.164
t = 2.010** t = 2.479**
wind 0.285 0.237
t = 1.812* t = 1.507
precip 15.255 14.845
t = 7.579*** t = 7.407***
quarter2 -2.060
t = -0.799
quarter3 -6.755
t = -2.164**
quarter4 -4.408
t = -2.164**
Constant 6.152 5.246
t = 2.058** t = 1.537
Observations 364 364
R2 0.154 0.175
Adjusted R2 0.147 0.161
Residual Std. Error 12.822 (df = 360) 12.718 (df = 357)
F Statistic 21.860*** (df = 3; 360) 12.593*** (df = 6; 357)
Note: p<0.1; p<0.05; p<0.01

Model Names

Dependent variable:
delay
OLS instrumental
variable
(1) (2) (3)
temp 0.079** 0.164** 0.041
(0.039) (0.066) (0.135)
wind 0.285* 0.237 0.250
(0.157) (0.157) (0.198)
precip 15.255*** 14.845*** 15.335***
(2.013) (2.004) (2.034)
quarter2 -2.060
(2.579)
quarter3 -6.755**
(3.121)
quarter4 -4.408**
(2.037)
Constant 6.152** 5.246 8.577
(2.989) (3.412) (8.797)
Observations 364 364 364
R2 0.154 0.175 0.152
Adjusted R2 0.147 0.161 0.145
Residual Std. Error 12.822 (df = 360) 12.718 (df = 357) 12.839 (df = 360)
F Statistic 21.860*** (df = 3; 360) 12.593*** (df = 6; 357)
Note: p<0.1; p<0.05; p<0.01

Multicolumn = F

Dependent variable:
delay delay delay
OLS OLS instrumental
variable
(1) (2) (3)
temp 0.079** 0.164** 0.041
(0.039) (0.066) (0.135)
wind 0.285* 0.237 0.250
(0.157) (0.157) (0.198)
precip 15.255*** 14.845*** 15.335***
(2.013) (2.004) (2.034)
quarter2 -2.060
(2.579)
quarter3 -6.755**
(3.121)
quarter4 -4.408**
(2.037)
Constant 6.152** 5.246 8.577
(2.989) (3.412) (8.797)
Observations 364 364 364
R2 0.154 0.175 0.152
Adjusted R2 0.147 0.161 0.145
Residual Std. Error 12.822 (df = 360) 12.718 (df = 357) 12.839 (df = 360)
F Statistic 21.860*** (df = 3; 360) 12.593*** (df = 6; 357)
Note: p<0.1; p<0.05; p<0.01

Add custom row

Dependent variable:
delay
(1) (2)
temp 0.079** 0.164**
(0.039) (0.066)
wind 0.285* 0.237
(0.157) (0.157)
precip 15.255*** 14.845***
(2.013) (2.004)
quarter2 -2.060
(2.579)
quarter3 -6.755**
(3.121)
quarter4 -4.408**
(2.037)
Constant 6.152** 5.246
(2.989) (3.412)
Fixed effects? No No
Results believable? Maybe Try again later
Observations 364 364
R2 0.154 0.175
Adjusted R2 0.147 0.161
Residual Std. Error 12.822 (df = 360) 12.718 (df = 357)
F Statistic 21.860*** (df = 3; 360) 12.593*** (df = 6; 357)
Note: p<0.1; p<0.05; p<0.01

Confidence intervals

Dependent variable:
delay
(1) (2)
temp 0.079** 0.164**
(0.002, 0.156) (0.034, 0.294)
wind 0.285* 0.237
(-0.023, 0.594) (-0.071, 0.545)
precip 15.255*** 14.845***
(11.310, 19.200) (10.917, 18.773)
quarter2 -2.060
(-7.116, 2.995)
quarter3 -6.755**
(-12.872, -0.638)
quarter4 -4.408**
(-8.401, -0.416)
Constant 6.152** 5.246
(0.293, 12.010) (-1.442, 11.934)
Observations 364 364
R2 0.154 0.175
Adjusted R2 0.147 0.161
Residual Std. Error 12.822 (df = 360) 12.718 (df = 357)
F Statistic 21.860*** (df = 3; 360) 12.593*** (df = 6; 357)
Note: p<0.1; p<0.05; p<0.01

Adjust confidence intervals

Dependent variable:
delay
(1) (2)
temp 0.079** 0.164**
(0.014, 0.144) (0.055, 0.273)
wind 0.285* 0.237
(0.026, 0.544) (-0.022, 0.496)
precip 15.255*** 14.845***
(11.944, 18.566) (11.548, 18.141)
quarter2 -2.060
(-6.303, 2.182)
quarter3 -6.755**
(-11.889, -1.622)
quarter4 -4.408**
(-7.759, -1.058)
Constant 6.152** 5.246
(1.235, 11.068) (-0.367, 10.858)
Observations 364 364
R2 0.154 0.175
Adjusted R2 0.147 0.161
Residual Std. Error 12.822 (df = 360) 12.718 (df = 357)
F Statistic 21.860*** (df = 3; 360) 12.593*** (df = 6; 357)
Note: p<0.1; p<0.05; p<0.01

Robust standard errors

Dependent variable:
delay
(1) (2)
temp 0.079** 0.079*
(0.039) (0.041)
wind 0.285* 0.285
(0.157) (0.177)
precip 15.255*** 15.255***
(2.013) (4.827)
Constant 6.152** 6.152**
(2.989) (3.074)
F Statistic (df = 3; 360) 12.879*** 7.73***
Observations 364 364
R2 0.154 0.154
Adjusted R2 0.147 0.147
Residual Std. Error (df = 360) 12.822 12.822
Note: p<0.1; p<0.05; p<0.01

Compress table output

Dependent variable:
delay
(1) (2)
temp 0.079** (0.039) 0.164** (0.066)
wind 0.285* (0.157) 0.237 (0.157)
precip 15.255*** (2.013) 14.845*** (2.004)
quarter2 -2.060 (2.579)
quarter3 -6.755** (3.121)
quarter4 -4.408** (2.037)
Constant 6.152** (2.989) 5.246 (3.412)
Observations 364 364
R2 0.154 0.175
Adjusted R2 0.147 0.161
Residual Std. Error 12.822 (df = 360) 12.718 (df = 357)
F Statistic 21.860*** (df = 3; 360) 12.593*** (df = 6; 357)
Note: p<0.1; p<0.05; p<0.01

Omit (example: fixed effects)

Dependent variable:
delay
(1) (2)
temp 0.079** 0.164**
(0.039) (0.066)
wind 0.285* 0.237
(0.157) (0.157)
precip 15.255*** 14.845***
(2.013) (2.004)
Constant 6.152** 5.246
(2.989) (3.412)
Observations 364 364
R2 0.154 0.175
Adjusted R2 0.147 0.161
Residual Std. Error 12.822 (df = 360) 12.718 (df = 357)
F Statistic 21.860*** (df = 3; 360) 12.593*** (df = 6; 357)
Note: p<0.1; p<0.05; p<0.01

Report Omitted

Dependent variable:
delay
(1) (2)
temp 0.079** 0.164**
(0.039) (0.066)
wind 0.285* 0.237
(0.157) (0.157)
precip 15.255*** 14.845***
(2.013) (2.004)
Constant 6.152** 5.246
(2.989) (3.412)
Quarter dummies? No No
Observations 364 364
R2 0.154 0.175
Adjusted R2 0.147 0.161
Residual Std. Error 12.822 (df = 360) 12.718 (df = 357)
F Statistic 21.860*** (df = 3; 360) 12.593*** (df = 6; 357)
Note: p<0.1; p<0.05; p<0.01

Omit Summary Stats

Dependent variable:
delay
(1) (2)
temp 0.079** 0.164**
(0.039) (0.066)
wind 0.285* 0.237
(0.157) (0.157)
precip 15.255*** 14.845***
(2.013) (2.004)
quarter2 -2.060
(2.579)
quarter3 -6.755**
(3.121)
quarter4 -4.408**
(2.037)
Constant 6.152** 5.246
(2.989) (3.412)
Observations 364 364
Adjusted R2 0.147 0.161
Residual Std. Error 12.822 (df = 360) 12.718 (df = 357)
Note: p<0.1; p<0.05; p<0.01

Omit Degrees of Freedom

Dependent variable:
delay
(1) (2)
temp 0.079** 0.164**
(0.039) (0.066)
wind 0.285* 0.237
(0.157) (0.157)
precip 15.255*** 14.845***
(2.013) (2.004)
quarter2 -2.060
(2.579)
quarter3 -6.755**
(3.121)
quarter4 -4.408**
(2.037)
Constant 6.152** 5.246
(2.989) (3.412)
Observations 364 364
R2 0.154 0.175
Adjusted R2 0.147 0.161
Residual Std. Error 12.822 12.718
F Statistic 21.860*** 12.593***
Note: p<0.1; p<0.05; p<0.01

Change significance cutoffs

Dependent variable:
delay
(1) (2)
temp 0.079* 0.164*
(0.039) (0.066)
wind 0.285 0.237
(0.157) (0.157)
precip 15.255*** 14.845***
(2.013) (2.004)
quarter2 -2.060
(2.579)
quarter3 -6.755*
(3.121)
quarter4 -4.408*
(2.037)
Constant 6.152* 5.246
(2.989) (3.412)
Observations 364 364
R2 0.154 0.175
Adjusted R2 0.147 0.161
Residual Std. Error 12.822 (df = 360) 12.718 (df = 357)
F Statistic 21.860*** (df = 3; 360) 12.593*** (df = 6; 357)
Note: p<0.05; p<0.01; p<0.001

Change Notes

Dependent variable:
delay
(1) (2)
temp 0.079** 0.164**
(0.039) (0.066)
wind 0.285* 0.237
(0.157) (0.157)
precip 15.255*** 14.845***
(2.013) (2.004)
quarter2 -2.060
(2.579)
quarter3 -6.755**
(3.121)
quarter4 -4.408**
(2.037)
Constant 6.152** 5.246
(2.989) (3.412)
Observations 364 364
R2 0.154 0.175
Adjusted R2 0.147 0.161
Residual Std. Error 12.822 (df = 360) 12.718 (df = 357)
F Statistic 21.860*** (df = 3; 360) 12.593*** (df = 6; 357)
New note label Sometimes you just have to start over.

Change decimal character

Dependent variable:
delay
(1) (2)
temp 0,079** 0,164**
(0,039) (0,066)
wind 0,285* 0,237
(0,157) (0,157)
precip 15,255*** 14,845***
(2,013) (2,004)
quarter2 -2,060
(2,579)
quarter3 -6,755**
(3,121)
quarter4 -4,408**
(2,037)
Constant 6,152** 5,246
(2,989) (3,412)
Observations 364 364
R2 0,154 0,175
Adjusted R2 0,147 0,161
Residual Std. Error 12,822 (df = 360) 12,718 (df = 357)
F Statistic 21,860*** (df = 3; 360) 12,593*** (df = 6; 357)
Note: p<0,1; p<0,05; p<0,01

Control number of decimal places

Dependent variable:
delay
(1) (2)
temp 0.1** 0.2**
(0.04) (0.1)
wind 0.3* 0.2
(0.2) (0.2)
precip 15.3*** 14.8***
(2.0) (2.0)
quarter2 -2.1
(2.6)
quarter3 -6.8**
(3.1)
quarter4 -4.4**
(2.0)
Constant 6.2** 5.2
(3.0) (3.4)
Observations 364 364
R2 0.2 0.2
Adjusted R2 0.1 0.2
Residual Std. Error 12.8 (df = 360) 12.7 (df = 357)
F Statistic 21.9*** (df = 3; 360) 12.6*** (df = 6; 357)
Note: p<0.1; p<0.05; p<0.01

Examples

Phillips curve regressions

Phillips Curve
Energy House Prices Rents
(1) (2) (3)
Unemployment -0.247*** -0.980*** -0.723***
(0.069) (0.073) (0.042)
N 4,987 4,049 4,444
Adjusted R2 0.002 0.043 0.062
Note: Panel of 35 OECD Countries. Standard-errors are clustered.