Model Comparison with Tidyverse & Radiant Packages

Libraries

library(tidyverse)
library(dplyr)
library(radiant)
library(kableExtra)

Overview

In my first blog post we discussion, the flexible of the tidyverse package. In this blog post we will be combining the tidyverse and radiant packages for some quick model comparison.

The radiant package is a platform-independent browser-based interface for business analytics in R, based on the Shiny package.

Build Model

Iris Data Set

fit1 <- lm(Sepal.Width ~ Petal.Length + Petal.Width, iris)
fit2 <- lm(mpg ~ wt + qsec, mtcars)

Model Comparison

full_join(glance(fit1), glance(fit2)) %>% 
  add_column(" " = c("Model 1", "Model 2")) %>% 
  select(" ", everything()) %>% 
  kable() %>% 
  kable_styling()
## Joining, by = c("r.squared", "adj.r.squared", "sigma", "statistic", "p.value", "df", "logLik", "AIC", "BIC", "deviance", "df.residual")
r.squared adj.r.squared sigma statistic p.value df logLik AIC BIC deviance df.residual
Model 1 0.2131034 0.2023973 0.3892661 19.90490 0 3 -69.80176 147.6035 159.6461 22.27463 147
Model 2 0.8264161 0.8144448 2.5961751 69.03311 0 3 -74.36025 156.7205 162.5834 195.46363 29

The function glance creates a single line data frame from a model best fit summary.