knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

AIC

Introduction

AIC stands for Akaike’s Information Criterion. It estimates the quality of a model, relative to each of other models. The lower AIC score is, the better the model is. Therefore, a model with lowest AIC - in comparison to others, is chosen.

AIC = n*log(residual sum of squares/n) + 2K

where:

Function

aic(y, y_pred, p)

Parameters:

Return:

Example

y <-  c(1,2,3,4)    
y_pred <- c(5,6,7,8)    
p <- 3  
aic(y, y_pred, p)   

BIC

Introduction:

BIC stands for Bayesian Information Criterion. Like AIC, it also estimates the quality of a model. When fitting models, it is possible to increase model fitness by adding more parameters. Doing this may results in model overfit. Both AIC and BIC helps to resolve this problem by using a penalty term for the number of parameters in the model. This term is bigger in BIC than in AIC.

BIC = n*log(residual sum of squares/n) + K*log(n)

where:

Function

bic(y, y_pred, p)

Parameters:

Return:

Example

y <-  c(1,2,3,4)    
y_pred <- c(5,6,7,8)    
p <- 3  
bic(y, y_pred, p)

Mallow's C_p

Introduction

Mallow's C_p is named for Colin Lingwood Mallows. It is used to assess the fit of regression model, finding the best model involving a subset of predictive variables available for predicting some outcome.

C_p = (SSE_p/MSE) - (n - 2p)

where:

Function

mallow(y, y_pred, y_sub, p, k)

Parameters:

Return:

Example

y <-  c(1,2,3,4)    
y_pred <- c(5,6,7,8)    
y_sub <- c(1,2,3,5) 
p <- 3  
k <-2   
mallow(y, y_pred, y_sub, p, k)  

Comparisons

broom package has a function finish_glance that outputs some of regression metrics in a table: Log likelihoods AIC BIC Deviance * Residual degrees of freedom

Although this function provides a table with some of the key metrics that we want to include in our package (AIC, BIC), it lacks of other metrics such as MSE and Mallow's C_p. Additionally, finish_glance's output table only include metrics for 1 model which might not be as easy to compare metrics of all models as out intended output table of comparison. That being said, our package can solve this problem, and be a united source for all popular regression model comparison metrics.



UBC-MDS/regscoreR documentation built on May 25, 2019, 1:36 p.m.