Learn R Programming

growR (version 1.3.0)

get_bias: Metric Functions

Description

Functions to calculate different performance metrics.

In the case of get_bias: Calculate the bias b, i.e. the average difference between predicted y and observed z values:

  bias = mean(y - z)

Usage

get_bias(predicted, observed, ...)

root_mean_squared(predicted, observed, ...)

mean_absolute_error(predicted, observed, ...)

Value

m A number representing the relative or absolute value for the metric.

Arguments

predicted

Vector containing the predictions y.

observed

Vector containing the observations z.

...

relative Boolean. If true give the result as a ratio to the average observation mean(ovserved).

Functions

  • root_mean_squared(): Calculate the square root of the average squared difference between prediction and observation:

    RMSE = sqrt(sum(predicted - observed)^2) / length(predicted)
    

  • mean_absolute_error(): Calculate the average of the absolute differences between prediction and observation:

    MAE = mean(abs(predicted - observed))
    

See Also

willmott()

Examples

Run this code
predicted = c(21.5, 22.2, 19.1)
observed = c(20, 20, 20)
get_bias(predicted, observed)
get_bias(predicted, observed, relative = FALSE)

root_mean_squared(predicted, observed)
root_mean_squared(predicted, observed, relative = FALSE)

mean_absolute_error(predicted, observed)
mean_absolute_error(predicted, observed, relative = FALSE)

Run the code above in your browser using DataLab