Model Comparisons with Stargazer Package

Libraries

Overview

The stargazer produces well designed LaTeX code, HTML code and ASCII text for well-formatted tables that hold regression analysis results from several models side-by-side. It can also output summary statistics and data frame content.

Data

pga <- read.csv("https://raw.githubusercontent.com/josephsimone/Data621/master/pgatour2006.csv", header = T)

Data Tidying

pga <- pga %>%
    select(PrizeMoney, DrivingAccuracy, GIR, PuttingAverage,
           BirdieConversion, SandSaves, Scrambling, PuttsPerRound)

Log Function Creation

pgaLog <- pga
pgaLog$logPrizeMoney <- log(pga$PrizeMoney)
pgaLog$PrizeMoney <- NULL

Stargazer Function

stargazer(pgaLog, type="html", header = F, title="Summary statistics")
Summary statistics
Statistic N Mean St. Dev. Min Pctl(25) Pctl(75) Max
DrivingAccuracy 196 63.380 5.413 49.750 59.758 66.965 78.430
GIR 196 65.186 2.722 56.870 63.522 66.770 74.150
PuttingAverage 196 1.780 0.025 1.712 1.763 1.796 1.851
BirdieConversion 196 28.982 2.207 23.170 27.508 30.553 35.660
SandSaves 196 48.972 5.828 33.910 45.130 52.870 63.640
Scrambling 196 57.494 3.162 49.020 55.260 59.457 66.450
PuttsPerRound 196 29.201 0.442 27.960 28.910 29.477 30.190
logPrizeMoney 196 10.378 0.980 7.714 9.762 10.967 13.404

Build Models

mod1 <- lm(PrizeMoney ~., pga)
mod2 <- lm(logPrizeMoney ~., pgaLog)
mod3 <- lm(logPrizeMoney ~ GIR + BirdieConversion + SandSaves + Scrambling + PuttsPerRound, pgaLog)

Model Summaries using Stargazer

stargazer(mod1, mod2, mod3, type="html", column.labels = c("Good", "Better", "Best"))
Dependent variable:
PrizeMoney logPrizeMoney
Good Better Best
(1) (2) (3)
DrivingAccuracy -1,835.830** -0.004
(889.161) (0.012)
GIR 9,671.334*** 0.199*** 0.197***
(3,309.355) (0.044) (0.029)
PuttingAverage -47,435.300 -0.466
(521,566.400) (6.906)
BirdieConversion 10,426.030*** 0.157*** 0.163***
(3,049.642) (0.040) (0.033)
SandSaves 1,182.058 0.015 0.016
(744.818) (0.010) (0.010)
Scrambling 4,741.258** 0.052 0.050**
(2,400.818) (0.032) (0.025)
PuttsPerRound 5,267.517 -0.343 -0.350
(35,765.740) (0.474) (0.231)
Constant -1,165,233.000** 0.194 -0.583
(587,382.900) (7.777) (7.159)
Observations 196 196 196
R2 0.406 0.558 0.557
Adjusted R2 0.384 0.541 0.546
Residual Std. Error 50,142.970 (df = 188) 0.664 (df = 188) 0.661 (df = 190)
F Statistic 18.387*** (df = 7; 188) 33.866*** (df = 7; 188) 47.875*** (df = 5; 190)
Note: p<0.1; p<0.05; p<0.01

As you can see from the above lines of code, stargazer makes it easy to produce visual model comparing charts simple and easy.