mse: Mean Squared Error (MSE)

Description Usage Arguments Details Value Examples

View source: R/modeling.R

Description

Calculates the mean square of the model by taking the mean of the sum of squares between the truth, y, and the predicted, y hat at each observation i.

Usage

1
mse(y, yhat)

Arguments

y

A vector of the true y values

yhat

A vector of predicted y hat values.

Details

The equation for MSE is:

mean((y-yhat)^2)

Value

The MSE in numeric form.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Set seed for reproducibility
set.seed(100)

# Generate data
n = 1e2

y = rnorm(n)
yhat = rnorm(n, 0.5)

# Compute
o = mse(y, yhat)

Example output



jjb documentation built on Jan. 8, 2020, 5:07 p.m.