23.2 Model Comparison

fit <- lm(metascore ~ log(budget), data = movies)
fit_b <- lm(metascore ~ log(budget) + log(us_gross), data = movies)
fit_c <- lm(metascore ~ log(budget) + log(us_gross) + runtime, data = movies)
coef_names <- c("Budget" = "log(budget)", "US Gross" = "log(us_gross)",
                "Runtime (Hours)" = "runtime", "Constant" = "(Intercept)")
export_summs(fit, fit_b, fit_c, robust = "HC3", coefs = coef_names)
## Warning in checkMatrixPackageVersion(): Package version inconsistency detected.
## TMB was built with Matrix version 1.2.18
## Current Matrix version is 1.3.2
## Please re-install 'TMB' from source using install.packages('TMB', type = 'source') or ask CRAN for a binary version of 'TMB' matching CRAN's 'Matrix' package
Table 23.1:
Model 1Model 2Model 3
Budget-2.43 ***-5.16 ***-6.70 ***
(0.44)   (0.62)   (0.67)   
US Gross       3.96 ***3.85 ***
       (0.51)   (0.48)   
Runtime (Hours)              14.29 ***
              (1.63)   
Constant105.29 ***81.84 ***83.35 ***
(7.65)   (8.66)   (8.82)   
N831       831       831       
R20.03    0.09    0.17    
Standard errors are heteroskedasticity robust. *** p < 0.001; ** p < 0.01; * p < 0.05.

Another package is stargazer

library("stargazer")
## 
## Please cite as:
##  Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.2. https://CRAN.R-project.org/package=stargazer
stargazer(attitude)
## 
## % Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
## % Date and time: Mon, May 10, 2021 - 5:15:15 PM
## \begin{table}[!htbp] \centering 
##   \caption{} 
##   \label{} 
## \begin{tabular}{@{\extracolsep{5pt}}lccccccc} 
## \\[-1.8ex]\hline 
## \hline \\[-1.8ex] 
## Statistic & \multicolumn{1}{c}{N} & \multicolumn{1}{c}{Mean} & \multicolumn{1}{c}{St. Dev.} & \multicolumn{1}{c}{Min} & \multicolumn{1}{c}{Pctl(25)} & \multicolumn{1}{c}{Pctl(75)} & \multicolumn{1}{c}{Max} \\ 
## \hline \\[-1.8ex] 
## rating & 30 & 64.633 & 12.173 & 40 & 58.8 & 71.8 & 85 \\ 
## complaints & 30 & 66.600 & 13.315 & 37 & 58.5 & 77 & 90 \\ 
## privileges & 30 & 53.133 & 12.235 & 30 & 45 & 62.5 & 83 \\ 
## learning & 30 & 56.367 & 11.737 & 34 & 47 & 66.8 & 75 \\ 
## raises & 30 & 64.633 & 10.397 & 43 & 58.2 & 71 & 88 \\ 
## critical & 30 & 74.767 & 9.895 & 49 & 69.2 & 80 & 92 \\ 
## advance & 30 & 42.933 & 10.289 & 25 & 35 & 47.8 & 72 \\ 
## \hline \\[-1.8ex] 
## \end{tabular} 
## \end{table}
## 2 OLS models
linear.1 <- lm(rating ~ complaints + privileges + learning + raises + critical,data = attitude)
linear.2 <- lm(rating ~ complaints + privileges + learning, data = attitude)
## create an indicator dependent variable, and run a probit model
attitude$high.rating <- (attitude$rating > 70)
probit.model <-
    glm(
        high.rating ~ learning + critical + advance,
        data = attitude,
        family = binomial(link = "probit")
    )
stargazer(linear.1,
          linear.2,
          probit.model,
          title = "Results",
          align = TRUE)
## 
## % Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
## % Date and time: Mon, May 10, 2021 - 5:15:15 PM
## % Requires LaTeX packages: dcolumn 
## \begin{table}[!htbp] \centering 
##   \caption{Results} 
##   \label{} 
## \begin{tabular}{@{\extracolsep{5pt}}lD{.}{.}{-3} D{.}{.}{-3} D{.}{.}{-3} } 
## \\[-1.8ex]\hline 
## \hline \\[-1.8ex] 
##  & \multicolumn{3}{c}{\textit{Dependent variable:}} \\ 
## \cline{2-4} 
## \\[-1.8ex] & \multicolumn{2}{c}{rating} & \multicolumn{1}{c}{high.rating} \\ 
## \\[-1.8ex] & \multicolumn{2}{c}{\textit{OLS}} & \multicolumn{1}{c}{\textit{probit}} \\ 
## \\[-1.8ex] & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)} & \multicolumn{1}{c}{(3)}\\ 
## \hline \\[-1.8ex] 
##  complaints & 0.692^{***} & 0.682^{***} &  \\ 
##   & (0.149) & (0.129) &  \\ 
##   & & & \\ 
##  privileges & -0.104 & -0.103 &  \\ 
##   & (0.135) & (0.129) &  \\ 
##   & & & \\ 
##  learning & 0.249 & 0.238^{*} & 0.164^{***} \\ 
##   & (0.160) & (0.139) & (0.053) \\ 
##   & & & \\ 
##  raises & -0.033 &  &  \\ 
##   & (0.202) &  &  \\ 
##   & & & \\ 
##  critical & 0.015 &  & -0.001 \\ 
##   & (0.147) &  & (0.044) \\ 
##   & & & \\ 
##  advance &  &  & -0.062 \\ 
##   &  &  & (0.042) \\ 
##   & & & \\ 
##  Constant & 11.011 & 11.258 & -7.476^{**} \\ 
##   & (11.704) & (7.318) & (3.570) \\ 
##   & & & \\ 
## \hline \\[-1.8ex] 
## Observations & \multicolumn{1}{c}{30} & \multicolumn{1}{c}{30} & \multicolumn{1}{c}{30} \\ 
## R$^{2}$ & \multicolumn{1}{c}{0.715} & \multicolumn{1}{c}{0.715} &  \\ 
## Adjusted R$^{2}$ & \multicolumn{1}{c}{0.656} & \multicolumn{1}{c}{0.682} &  \\ 
## Log Likelihood &  &  & \multicolumn{1}{c}{-9.087} \\ 
## Akaike Inf. Crit. &  &  & \multicolumn{1}{c}{26.175} \\ 
## Residual Std. Error & \multicolumn{1}{c}{7.139 (df = 24)} & \multicolumn{1}{c}{6.863 (df = 26)} &  \\ 
## F Statistic & \multicolumn{1}{c}{12.063$^{***}$ (df = 5; 24)} & \multicolumn{1}{c}{21.743$^{***}$ (df = 3; 26)} &  \\ 
## \hline 
## \hline \\[-1.8ex] 
## \textit{Note:}  & \multicolumn{3}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
## \end{tabular} 
## \end{table}
# Latex
stargazer(
    linear.1,
    linear.2,
    probit.model,
    title = "Regression Results",
    align = TRUE,
    dep.var.labels = c("Overall Rating", "High Rating"),
    covariate.labels = c(
        "Handling of Complaints",
        "No Special Privileges",
        "Opportunity to Learn",
        "Performance-Based Raises",
        "Too Critical",
        "Advancement"
    ),
    omit.stat = c("LL", "ser", "f"),
    no.space = TRUE
)
# ASCII text output
stargazer(
    linear.1,
    linear.2,
    type = "text",
    title = "Regression Results",
    dep.var.labels = c("Overall Rating", "High Rating"),
    covariate.labels = c(
        "Handling of Complaints",
        "No Special Privileges",
        "Opportunity to Learn",
        "Performance-Based Raises",
        "Too Critical",
        "Advancement"
    ),
    omit.stat = c("LL", "ser", "f"),
    ci = TRUE,
    ci.level = 0.90,
    single.row = TRUE
)
## 
## Regression Results
## ========================================================================
##                                        Dependent variable:              
##                          -----------------------------------------------
##                                          Overall Rating                 
##                                    (1)                     (2)          
## ------------------------------------------------------------------------
## Handling of Complaints   0.692*** (0.447, 0.937) 0.682*** (0.470, 0.894)
## No Special Privileges    -0.104 (-0.325, 0.118)  -0.103 (-0.316, 0.109) 
## Opportunity to Learn      0.249 (-0.013, 0.512)   0.238* (0.009, 0.467) 
## Performance-Based Raises -0.033 (-0.366, 0.299)                         
## Too Critical              0.015 (-0.227, 0.258)                         
## Advancement              11.011 (-8.240, 30.262) 11.258 (-0.779, 23.296)
## ------------------------------------------------------------------------
## Observations                       30                      30           
## R2                                0.715                   0.715         
## Adjusted R2                       0.656                   0.682         
## ========================================================================
## Note:                                        *p<0.1; **p<0.05; ***p<0.01
stargazer(
    linear.1,
    linear.2,
    probit.model,
    title = "Regression Results",
    align = TRUE,
    dep.var.labels = c("Overall Rating", "High Rating"),
    covariate.labels = c(
        "Handling of Complaints",
        "No Special Privileges",
        "Opportunity to Learn",
        "Performance-Based Raises",
        "Too Critical",
        "Advancement"
    ),
    omit.stat = c("LL", "ser", "f"),
    no.space = TRUE
)

Correlation Table

correlation.matrix <- cor(attitude[,c("rating","complaints","privileges")])
stargazer(correlation.matrix, title="Correlation Matrix")