mbadtools

The goal of mbadtools is to provide MBAD students with the key packages the course focuses on, and to also provide some tools (in the form of functions) for certain tasks often encountered in your work.

Installation

You can install the current version of mbadtools like so; it installs latest version, and skips if it’s already there:

# pak::pak("bhartman2/mbadtools")
install.packages("mbadtools", repos = c('https://bhartman2.r-universe.dev', 'https://cloud.r-project.org'))

Notebook or Script Usage

This is a basic example which shows you how to load mbadtools; that is, make mbadtools available to your notebook. Any messages are suppressed here, but you can make them available by setting ‘message=TRUE’.

library(mbadtools)

Packages Loaded

Current list of the packages loaded with mbadtools.

Package Use
tidyverse host of packages for modern data and code handling in R
tidymodels host of packages for tidy modeling
conflicted prefer certain conflicts in function names
ggfortify tools to improve use of ggplot2 graphics
GGally tools for ggplot2 graphics especially the ggpairs() function
skimr better than summary() for quickly exploring and summarizing data
gt displaying neat, readable tabular data
patchwork tools for combining ggplot objects
lmtest tools for advanced statistical modeling and data analysis
gh4x for the geom_pointpath() function
bvartools bayesian VAR
vars simple VAR
vip interpretability variable importance functions
pdp interpretability partial dependence importance functions
pre interpretability RuleFit surrogates

Basic Notebook Template

A basic notebook template is provided to help you set up a notebook to write an assignment. It is an .Rmd file like a miniature paper with code and output interspersed, and with typical key headings you may want to include.

View Basic Notebook Template

Functions in mbadtools

Some useful functions are included in mbadtools.

Function Description
gg_residual_plots() displays 9 different residual plots for linear regression
gg_partial_residual_plots() displays partial residual plots for linear regression
gt_add_significance() gt table for dataframe with a p.value column; adds color when p.value is significant
GrangerTest() performs Granger causality tests for time series data frame
GrangerPlot() plots results of GrangerTest()
GrangerTestPvals() performs Granger causality tests for time series data
GrangerTestTune() plots results of GrangerTestPvals()

The first 3 are demonstrated in Using mbadtools.

The Granger Causality functions are demonstrated in Granger MoodysDemo

Others can be viewed in the mbadtools help.