metric_deviance: metric_deviance

Description Usage Arguments Value See Also Examples

View source: R/metric_deviance.R

Description

Returns The deviance of the predictions. Note: Predictions should be annualized (independent of exposure) Note: Low is good. 0 is perfect model

Usage

1
2
3
4
5
6
7
8
9
metric_deviance(
  actual,
  predicted,
  weight = NULL,
  family = "gaussian",
  na.rm = FALSE,
  rebase = FALSE,
  tweedie_power = NULL
)

Arguments

actual

Array[Numeric] - Values we are aiming to predict.

predicted

Array[Numeric] - Values that we have predicted.

weight

Optional: Array[Numeric] - Weighting of predictions. If NULL even weighting is used

family

String - family of distribution. Must be in c("gaussian", "poisson", "gamma", "tweedie", "binomial")

na.rm

Optional: boolean - If FALSE function will return NA is any value in NA

rebase

Optional: boolean - If TRUE predictions weighted mean will be rebased to match actual mean

tweedie_power

Numeric - power of tweedie distribution if chosen in family

Value

Numeric: deviance of the predictions

See Also

Other Metrics: metric_mae(), metric_nloglik(), metric_pode(), metric_pove(), metric_rmse()

Examples

1
2
3
4
5
6
7
set.seed(666)
actual <- rep(10, 10)
predicted <- rnorm(n = 10, mean = 10, sd = 1)
weight <- pmax(rnorm(n = 10, mean = 10, sd = 1) , 0)

metric_deviance(actual, predicted, family="gaussian")
metric_deviance(actual, predicted, weight, family="gaussian")

gloverd2/admr documentation built on Dec. 2, 2020, 11:16 p.m.