calculate_metrics {dendroTools}R Documentation

calculate_metrics

Description

Calculates performance metrics for train and test data. Calculated performance metrics are correlation coefficient (r), root mean squared error (RMSE), root relative squared error (RRSE), index of agreement (d), reduction of error (RE), coefficient of efficiency (CE), detrended efficiency (DE) and bias.

Usage

calculate_metrics(
  train_predicted,
  test_predicted,
  train_observed,
  test_observed,
  digits = 4,
  formula,
  test
)

Arguments

train_predicted

a vector indicating predicted data for training set

test_predicted

a vector indicating predicted data for testing set

train_observed

a vector indicating observed data for training set

test_observed

a vector indicating observed data for training set

digits

integer of number of digits to be displayed

formula

an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. This additional argument is needed to calculate DE metrics.

test

data frame with test data.

Value

a data frame of calculated test and train metrics

References

Briffa, K.R., Jones, P.D., Pilcher, J.R., Hughes, M.K., 1988. Reconstructing summer temperatures in northern Fennoscandinavia back to A.D.1700 using tree ring data from Scots Pine. Arct. Alp. Res. 20, 385-394.

Fritts, H.C., 1976. Tree Rings and Climate. Academic Press, London 567 pp.

Lorenz, E.N., 1956. Empirical Orthogonal Functions and Statistical Weather Prediction. Massachusetts Institute of Technology, Department of Meteorology.

Willmott, C.J., 1981. On the validation of models. Phys. Geogr. 2, 184-194.

Witten, I.H., Frank, E., Hall, M.A., 2011. Data Mining: Practical Machine Learning Tools and Techniques, 3rd ed. Morgan Kaufmann Publishers, Burlington 629 pp.

Examples


data(example_dataset_1)
test_data <- example_dataset_1[1:30, ]
train_data <- example_dataset_1[31:55, ]
lin_mod <- lm(MVA ~., data = train_data)
train_predicted <- predict(lin_mod, train_data)
test_predicted <- predict(lin_mod, test_data)
train_observed <- train_data[, 1]
test_observed <- test_data[, 1]
calculate_metrics(train_predicted, test_predicted, train_observed,
test_observed, test = test_data, formula = MVA ~.)

test_data <- example_dataset_1[1:20, ]
train_data <- example_dataset_1[21:55, ]
library(brnn)
lin_mod <- brnn(MVA ~., data = train_data)
train_predicted <- predict(lin_mod, train_data)
test_predicted <- predict(lin_mod, test_data)
train_observed <- train_data[, 1]
test_observed <- test_data[, 1]
calculate_metrics(train_predicted, test_predicted, train_observed,
test_observed, test = test_data, formula = MVA ~.)


[Package dendroTools version 1.2.13 Index]