mperf: Model performance

View source: R/mperf.R

mperfR Documentation

Model performance

Description

Computes indices of model performance from real data and predictions.

Usage

mperf(
  Y,
  Yh,
  global = TRUE,
  to_compute = c("aCC", "aRE", "MSE", "aRMSE"),
  is.t = FALSE
)

Arguments

Y, Yh

The data and predictions matrices respectively with variables as columns, observations as rows ; must have the same dimensions.

global

if TRUE (default), averages the index over all variables.

to_compute

a vector with the indices to compute among c("aCC", "aRE", "MSE", "aRMSE").

is.t

boolean ; if TRUE, Y and Yh should be transposed.

Indices

Let y and \hat{y} be the data and predictions respectively, with m dependant variables and n observations. The model performance indices are defined as follows.

aCC

average Correlation Coefficient.

aCC=\frac{1}{m}\sum^{m}_{i=1}{CC}=\frac{1}{m}\sum^{m}_{i=1}{\cfrac{\sum^{n}_{j=1}{(y_i^{(j)}-\bar{y}_i)(\hat{y}_i^{(j)}-\bar{\hat{y}}_i)}}{\sqrt{\sum^{n}_{j=1}{(y_i^{(j)}-\bar{y}_i)^2(\hat{y}_i^{(j)}-\bar{\hat{y}}_i)^2}}}}

aRE

average Relative Error.

a\delta = \frac{1}{m}\sum^{m}_{i=1}{\delta} = \frac{1}{m} \sum^{m}_{i=1} \frac{1}{n} \sum^{n}_{j=1} \cfrac{| y_i^{(j)} - \hat{y}_i^{(j)} | }{y_i^{(j)}}

MSE

Mean Squared Error.

MSE = \frac{1}{m} \sum^{m}_{i=1} \frac{1}{n} \sum^{n}_{j=1} (y_i^{(j)} - \hat{y}_i^{(j)} )^2

aRMSE

average Root Mean Squared Error.

aRMSE = \frac{1}{m}\sum^{m}_{i=1}{RMSE} = \frac{1}{m} \sum^{m}_{i=1} \sqrt{\cfrac{\sum^{n}_{j=1} (y_i^{(j)} - \hat{y}_i^{(j)} )^2}{n}}

Examples


m1 <- matrix(rnorm(1000), ncol = 5)
m2 <- matrix(rnorm(1000), ncol = 5)
mperf(m1, m2, is.t = TRUE)


LBMC/wormAge documentation built on April 6, 2023, 3:52 a.m.