comp_mods: Model Performace Comparison

Description Usage Arguments Value Examples

View source: R/comp_mods.R

Description

This function takes in one or more linear regression models and compares the RMSE, R2 and MAE of those models with or without a new input data.

Usage

1
comp_mods(mod1, ..., newdata = NULL)

Arguments

mod1

an object containing results returned by lm function

...

additional lm model object

newdata

newdata than used for training the model. By default NULL and the function evaluated model performance based on training data

Value

a dataframe with each row representing an input model and three columns of model performance evaluation criteria (RMSE, R2 and MAE)

Examples

1
2
3
4
5
6
7
8
9
train <- mtcars[1:20,]
test <- mtcars[21:30,]

mod1 <- lm(mpg~wt, train)
mod2 <- lm(mpg~cyl, train)
mod3 <- lm(mpg~wt+cyl, train)
mod4 <- lm(mpg~carb, train)

comp_mods(mod1, mod2, mod3, mod4, newdata = test)

asfarlathif/RefineMod documentation built on Dec. 31, 2020, 7:51 p.m.