mse: Mean Squared Error

Description Usage Arguments Examples

View source: R/risk.R

Description

Compute the mean squared error (risk under L2 loss).

Usage

1
mse(prediction, outcome)

Arguments

prediction

A numeric vector of predictions.

outcome

A numeric vector of outcomes actually observed.

Examples

1
2
3
4
5
6
7
x <- rnorm(100)
y <- x^2
test_x <- rnorm(100)
test_y <- test_x^2
mod <- glm(y ~ x)
pred <- predict(mod, newx = as.data.frame(test_x))
error <- mse(prediction = pred, outcome = test_y)

nhejazi/nima documentation built on March 10, 2020, 1:10 a.m.