calc_nrmse: Calculates the Normalized Root Mean Square Error (NRMSE) for...

Description Usage Arguments Details Value See Also Examples

View source: R/calc_nrmse.R

Description

calc_nrmse is a wrapper function that applies the nrmse function to a list of models given the input indicator and pressure observations. The function calculates first the predicted values for each model, which are then used for the NRMSE computation. The normalization method and transformation types required for nrmse can be set for all models the same or individually.

Usage

1
2
3
4
5
6
7
8
calc_nrmse(
  press,
  ind,
  model,
  method = "sd",
  transformation = "none",
  trans_function = "none"
)

Arguments

press

A list of vectors containing the pressure values.

ind

A list of vectors containing the indicator values.

model

A list containing the models.

method

A character string or vector of the same length as the model list indicating the value(s) to be used for the normalization of the RMSE. The default is the standard deviation, alternative methods are the "mean", "maxmin" (difference between the maximum and minimum observed values) or "iq" (interquartile) (see also nrmse).

transformation

A character string or vector of the same length as the model list indicating the type of transformation applied to the observations prior to the analysis. Choose one of the following: "none" (default), "sqrt", "4thrt" (fourth root), "log" (natural logarithm), "log10" (common, i.e. base 10, logarithm), "log2" (binary logarithm), "log1p" (i.e. log(1+x)), "arcsine" (if data is proportional, NOT percentage) or "other".

trans_function

If transformation is set to ""other" for some or all models, the function for the back-transformation needs to be defined here as single character string (applied to all models ) or as character vector (with one string per model). If no special transformation was applied use default setting "none".

Details

This wrapper function is used within the model_gam and model_gamm functions with the default "sd" method and no transformation. If another normalization is required or indicators where standardized prior to the analysis, this wrapper function should be applied to the final model output tibble to compute NRMSE that are based on the original indicator scale (advised for cross-indicator comparisons).

The more common transformation types applied to the indicator can be simply specified in the transformation argument, which will invoke the respective back-transformation of the observed and predicted indicator values before the NRMSE calculation. Any other transformation applied should be indicated with transformation = "other" and the respective back-transformation (simply the inverse of the original transformation) specified under trans_function, e.g. e.g. "5^x" if observations log(x, base = 5) transformed or "exp(x) - 0.001" if observations log(x + 0.001) transformed.

Missing values in obs and pred are removed before the computation proceeds, and only those positions with non-missing values in both pred and obs are considered in the computation.

Value

The function returns a numerical vector of the same length then the input lists, with one NRMSE value for each model.

NOTE: If NA is returned for some models it means that either no model is available or that not enough observations with both indicator and pressure values are available (minimum of 2 required).

See Also

nrmse, model_gam and model_gamm

Examples

1
2
3
4
5
# Calculate NRMSE for the indicators TZA (~Fcod), which was let's say
# log(x+ 0.001)-transformed, and MS (~TSum), which was not transformed:
calc_nrmse(press = ind_init_ex$press_test[7:8], ind = ind_init_ex$ind_test[7:8],
model = model_gam_ex$model[7:8], method = "sd", transformation = c("other", "none"),
trans_function = c("exp(x) - 0.001", "none") )

saskiaotto/INDperform documentation built on Oct. 27, 2021, 10:33 p.m.