Package {hydroeval}


Title: Hydrological Evaluation Metrics and Goodness-of-Fit Summaries
Version: 0.1.0
Author: Pritam Parida [aut, cre]
Maintainer: Pritam Parida <pritamparida432@gmail.com>
Description: Computes scalar performance metrics and goodness-of-fit summaries for comparing simulated and observed hydrological or regression values. Provides error metrics, percentage bias, Nash-Sutcliffe efficiency, Kling-Gupta efficiency variants, correlation measures, agreement indices, and comparison tables via gof() and gof_compare(). Metric definitions are registry-governed with shared validation, provenance-aware wrappers, and explicit handling of undefined or degenerate cases. Methods include Nash and Sutcliffe (1970) <doi:10.1016/0022-1694(70)90255-6>, Gupta et al. (2009) <doi:10.1016/j.jhydrol.2009.08.003>, Kling et al. (2012) <doi:10.1016/j.jhydrol.2012.01.011>, and Willmott et al. (2012) <doi:10.1002/joc.2419>.
License: MIT + file LICENSE
Encoding: UTF-8
Language: en-US
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
RoxygenNote: 7.3.3
NeedsCompilation: no
Packaged: 2026-05-08 09:55:41 UTC; CodexSandboxOffline
Repository: CRAN
Date/Publication: 2026-05-13 07:30:51 UTC

Concordance Correlation Coefficient

Description

Compute Lin's concordance correlation coefficient using the direct formula with 'stats::var' and 'stats::cov' sample moments.

Usage

ccc(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. Inputs fail with 'hydroeval_metric_degeneracy' only when the concordance denominator is zero. A one-series-constant case may still be valid when that denominator remains positive.

Value

Unnamed length-1 numeric value ('double') on success.

References

Lin, L. I.-K. (1989). A Concordance Correlation Coefficient to Evaluate Reproducibility. Biometrics, 45(1), 255-268.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

ccc(observed, simulated)

Index of Agreement

Description

Compute Willmott's original index of agreement.

Usage

d(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. Inputs fail with 'hydroeval_metric_degeneracy' when the agreement denominator collapses to zero.

Value

Unnamed length-1 numeric value ('double') on success.

References

Willmott, C. J. (1981). On the Validation of Models. Physical Geography, 2, 184-194.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

d(observed, simulated)

Refined Index of Agreement

Description

Compute the refined index of agreement using the approved piecewise definition from Willmott et al. (2012).

Usage

d_r(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. Inputs fail with 'hydroeval_metric_degeneracy' when the refined agreement denominator collapses to zero.

Value

Unnamed length-1 numeric value ('double') on success.

References

Willmott, C. J., S. M. Robeson, and K. Matsuura (2012). A Refined Index of Model Performance. International Journal of Climatology, 32(13), 2088-2094.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

d_r(observed, simulated)

Explained Variance Score

Description

Compute explained variance score as '1 - var(observed - simulated) / var(observed)'.

Usage

evs(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. Constant observed series fail with 'hydroeval_metric_degeneracy'. 'hydroeval' cites Pedregosa et al. (2011) here as implementation-standard provenance, not as the original definitional source of EVS.

Value

Unnamed length-1 numeric value ('double') on success.

References

Pedregosa, F., G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay (2011). Scikit-learn: Machine Learning in Python. Journal of Machine Learning Research, 12, 2825-2830.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

evs(observed, simulated)

Registry-Driven Goodness-of-Fit Summary

Description

Compute a strict multi-metric goodness-of-fit summary using the currently implemented public metric wrappers.

Usage

gof(observed, simulated, metrics = "default", na_policy = c("omit", "fail"))

## S3 method for class 'hydroeval_gof'
as.matrix(x, ...)

## S3 method for class 'hydroeval_gof'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

## S3 method for class 'hydroeval_gof'
print(x, ...)

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values.

metrics

Either '"default"', '"all"', or a character vector of canonical metric IDs from the current public registry surface. '"all"' resolves through the current public planned registry view.

na_policy

NA handling policy passed through the existing public metric wrappers. Supported values are '"omit"' and '"fail"'.

x

A 'hydroeval_gof' object.

...

Unused.

row.names

'NULL' to use the default sequential row names.

optional

Unused.

Details

Metric selection is resolved through the package registry only. Output rows use registry-driven scientific 'display_label' values rather than canonical metric IDs.

This orchestrator remains strict. It does not silently skip unknown metrics, use tolerant partial-success behavior, or introduce hidden data handling beyond the explicitly chosen 'na_policy'. Existing public metric wrappers remain the execution layer for all formulas. Printed output is a one-column matrix-style comparison view; stored values remain numeric and unrounded.

Value

A list of class 'hydroeval_gof' with components:

values

Named numeric vector of metric results, keyed by canonical metric ID.

metric_ids

Character vector of canonical metric IDs in output order.

display_labels

Character vector of scientific display labels in output order.

request

List containing request metadata, including the original metric selector, resolved metric IDs, 'na_policy', and selection mode.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

gof(
  observed = observed,
  simulated = simulated,
  metrics = c("mae", "nse", "kge_2009")
)


Multi-Dataset Goodness-of-Fit Comparison

Description

Compare multiple observed/simulated dataset pairs by delegating each pair to the existing strict 'gof()' orchestrator and combining the resulting matrix-style summaries column-wise.

Usage

gof_compare(datasets, metrics = "default", na_policy = c("omit", "fail"))

## S3 method for class 'hydroeval_gof_compare'
as.matrix(x, ...)

## S3 method for class 'hydroeval_gof_compare'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

## S3 method for class 'hydroeval_gof_compare'
print(x, ...)

Arguments

datasets

Named list of datasets. Each dataset must be a list containing exactly 'obs' and 'sim'.

metrics

Either '"default"', '"all"', or a character vector of canonical metric IDs to pass through unchanged to 'gof()'.

na_policy

NA handling policy passed through unchanged to 'gof()'.

x

A 'hydroeval_gof_compare' object.

...

Unused.

row.names

'NULL' to use the default sequential row names.

optional

Unused.

Details

Each input dataset must be a named list with exactly two components: 'obs' and 'sim'. The resulting comparison object is a numeric matrix subclass that keeps registry-driven scientific 'display_label' values as row names and dataset names as column names.

'gof_compare()' is a thin comparison layer only. It does not change 'gof()' behavior, relax metric selection rules, or alter metric formulas. Every dataset is evaluated independently through 'gof()', and all combined summaries must resolve to identical 'metric_ids' and 'display_labels' before a comparison matrix is created.

Value

A numeric matrix of class 'hydroeval_gof_compare' with row names given by scientific 'display_label' values and column names given by the input dataset names. Attributes include:

metric_ids

Character vector of canonical metric IDs in row order.

display_labels

Character vector of scientific display labels in row order.

request

List containing request metadata, including dataset names, the original metric selector, resolved metric IDs, 'na_policy', and selection mode inherited from the first 'gof()' result.

Examples

datasets <- list(
  baseline = list(
    obs = c(1, 2, 3, 4),
    sim = c(1.2, 1.9, 3.1, 3.8)
  ),
  calibrated = list(
    obs = c(1, 2, 3, 4),
    sim = c(1.0, 2.0, 2.9, 4.1)
  )
)

gof_compare(
  datasets = datasets,
  metrics = c("mae", "nse", "kge_2009")
)


Kling-Gupta Efficiency (2009)

Description

Compute the approved 2009 Kling-Gupta Efficiency variant for paired simulated and observed values.

Usage

kge_2009(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

This wrapper is intentionally variant-specific. 'hydroeval' does not expose bare 'kge' while multiple KGE formulations remain semantically distinct.

Invalid input fails with 'hydroeval_validation_error'. Structurally valid inputs fail with 'hydroeval_metric_degeneracy' when the approved 2009 components become undefined, including constant observed series, constant simulated series, or zero observed mean. A zero simulated mean does not itself invalidate this 2009 formulation when the observed mean is non-zero.

Value

Unnamed length-1 numeric value ('double') on success.

References

Gupta, H. V., H. Kling, K. K. Yilmaz, and G. F. Martinez (2009). Decomposition of the Mean Squared Error and NSE Performance Criteria: Implications for Improving Hydrological Modelling. Journal of Hydrology, 377(1-2), 80-91.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

kge_2009(observed, simulated)

Kling-Gupta Efficiency (2012)

Description

Compute the approved 2012 Kling-Gupta Efficiency variant for paired simulated and observed values.

Usage

kge_2012(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. Structurally valid inputs fail with 'hydroeval_metric_degeneracy' when KGE 2012 components become undefined, including constant observed series, constant simulated series, zero observed mean, or zero simulated mean. Unlike 'kge_2009', this variant uses the coefficient-of-variation ratio ('gamma') rather than the simple standard-deviation ratio ('alpha'), so zero simulated mean is also degeneracy-relevant here. This wrapper is intentionally variant-specific and does not expose bare 'kge'.

Value

Unnamed length-1 numeric value ('double') on success.

References

Kling, H., M. Fuchs, and M. Paulin (2012). Runoff Conditions in the Upper Danube Basin under an Ensemble of Climate Change Scenarios. Journal of Hydrology, 424-425, 264-277.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

kge_2012(observed, simulated)

Mean Absolute Error

Description

Compute mean absolute error between paired simulated and observed values.

Usage

mae(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

'hydroeval' documents MAE against Willmott and Matsuura (2005) as the approved methodological anchor for the current public residual-metric surface.

Invalid input fails with 'hydroeval_validation_error'. MAE has no additional metric-specific degeneracy beyond the shared structural validation contract in the current approved public surface.

Value

Unnamed length-1 numeric value ('double') on success.

References

Willmott, C. J., and K. Matsuura (2005). Advantages of the Mean Absolute Error (MAE) over the Root Mean Square Error (RMSE) in Assessing Average Model Performance. Climate Research, 30(1), 79-82.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

mae(observed, simulated)

Mean Absolute Percentage Error

Description

Compute mean absolute percentage error on a percent scale.

Usage

mape(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. Any retained zero in 'observed' fails with 'hydroeval_metric_degeneracy' because the percentage denominator is undefined.

Value

Unnamed length-1 numeric value ('double') on success.

References

Hyndman, R. J., and A. B. Koehler (2006). Another Look at Measures of Forecast Accuracy. International Journal of Forecasting, 22(4), 679-688. doi:10.1016/j.ijforecast.2006.03.001.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

mape(observed, simulated)

Maximum Absolute Error

Description

Compute 'max(abs(simulated - observed))' for paired values.

Usage

max_error(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. This metric has no additional metric-specific degeneracy beyond shared structural validation.

Value

Unnamed length-1 numeric value ('double') on success.

References

Draper, N. R., and H. Smith (1998). Applied Regression Analysis. 3rd ed. New York: John Wiley and Sons.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

max_error(observed, simulated)

Mean Error

Description

Compute mean signed error, defined as 'mean(simulated - observed)'.

Usage

me(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. This metric has no additional metric-specific degeneracy beyond shared structural validation.

Value

Unnamed length-1 numeric value ('double') on success.

References

Draper, N. R., and H. Smith (1998). Applied Regression Analysis. 3rd ed. New York: John Wiley and Sons.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

me(observed, simulated)

Median Absolute Error

Description

Compute the median of 'abs(simulated - observed)'.

Usage

medae(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. This metric has no additional metric-specific degeneracy beyond shared structural validation.

Value

Unnamed length-1 numeric value ('double') on success.

References

Draper, N. R., and H. Smith (1998). Applied Regression Analysis. 3rd ed. New York: John Wiley and Sons.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

medae(observed, simulated)

Mean Squared Error

Description

Compute mean squared error for paired simulated and observed values.

Usage

mse(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. This metric has no additional metric-specific degeneracy beyond shared structural validation.

Value

Unnamed length-1 numeric value ('double') on success.

References

Draper, N. R., and H. Smith (1998). Applied Regression Analysis. 3rd ed. New York: John Wiley and Sons.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

mse(observed, simulated)

Mean Squared Logarithmic Error

Description

Compute mean squared logarithmic error using 'log1p' on both paired inputs.

Usage

msle(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. Any retained negative value in 'observed' or 'simulated' fails with 'hydroeval_metric_degeneracy'. 'hydroeval' cites Pedregosa et al. (2011) here as implementation-standard provenance, not as the original definitional source of MSLE.

Value

Unnamed length-1 numeric value ('double') on success.

References

Pedregosa, F., G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay (2011). Scikit-learn: Machine Learning in Python. Journal of Machine Learning Research, 12, 2825-2830.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

msle(observed, simulated)

Normalized Root Mean Squared Error

Description

Compute normalized RMSE with the package-approved observed-range normalization, 'rmse / (max(observed) - min(observed))'.

Usage

nrmse(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. Constant observed series fail with 'hydroeval_metric_degeneracy' because the observed range denominator is zero. This wrapper returns an observed-range-normalized ratio, not a percent. No alternative NRMSE normalization variants are exposed in this package wave.

Value

Unnamed length-1 numeric value ('double') on success.

References

Draper, N. R., and H. Smith (1998). Applied Regression Analysis. 3rd ed. New York: John Wiley and Sons.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

nrmse(observed, simulated)

Nash-Sutcliffe Efficiency

Description

Compute Nash-Sutcliffe Efficiency (NSE) for paired simulated and observed values.

Usage

nse(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

NSE equals 1 under perfect agreement and 0 for a mean-predictor baseline on the observed series.

Invalid input fails with 'hydroeval_validation_error'. Structurally valid inputs with constant observed series fail with 'hydroeval_metric_degeneracy' because the observed variance term in the NSE denominator is undefined.

Value

Unnamed length-1 numeric value ('double') on success.

References

Nash, J. E., and J. V. Sutcliffe (1970). River Flow Forecasting through Conceptual Models Part I: A Discussion of Principles. Journal of Hydrology, 10(3), 282-290.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

nse(observed, simulated)

Percent Bias

Description

Compute signed percent bias for paired simulated and observed values.

Usage

pbias(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Positive values indicate aggregate overestimation by 'simulated' relative to 'observed', negative values indicate aggregate underestimation, and zero is the ideal target. 'hydroeval' treats Gupta et al. (1999) as the definitional provenance for this signed formulation and Moriasi et al. (2007) only as interpretive or evaluation guidance.

Invalid input fails with 'hydroeval_validation_error'. Structurally valid inputs with zero observed sum fail with 'hydroeval_metric_degeneracy' because normalization against the observed sum is undefined.

Value

Unnamed length-1 numeric value ('double') on success.

References

Gupta, H. V., S. Sorooshian, and P.-A. Yapo (1999). Status of Automatic Calibration for Hydrologic Models: Comparison with Multilevel Expert Calibration. Journal of Hydrologic Engineering, 4(2), 135-143.

Moriasi, D. N., J. G. Arnold, M. W. Van Liew, R. L. Bingner, R. D. Harmel, and T. L. Veith (2007). Model Evaluation Guidelines for Systematic Quantification of Accuracy in Watershed Simulations. Transactions of the ASABE, 50(3), 885-900.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

pbias(observed, simulated)

Pearson Correlation Coefficient

Description

Compute Pearson correlation for paired simulated and observed values.

Usage

r(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. Constant observed or simulated series fail with 'hydroeval_metric_degeneracy' because correlation is undefined.

Value

Unnamed length-1 numeric value ('double') on success.

References

Pearson, K. (1895). Notes on Regression and Inheritance in the Case of Two Parents. Proceedings of the Royal Society of London, 58, 240-242.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

r(observed, simulated)

Coefficient of Determination

Description

Compute the package-approved 'r_squared' definition as squared Pearson correlation, 'cor(observed, simulated)^2'.

Usage

r_squared(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. Constant observed or simulated series fail with 'hydroeval_metric_degeneracy' because correlation is undefined. This wrapper intentionally uses squared correlation rather than '1 - SSE / SST', so it is not interchangeable with 'nse' and should not be read as a broader regression-model fit shorthand.

Value

Unnamed length-1 numeric value ('double') on success.

References

Draper, N. R., and H. Smith (1998). Applied Regression Analysis. 3rd ed. New York: John Wiley and Sons.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

r_squared(observed, simulated)

Relative Absolute Error

Description

Compute relative absolute error using the observed-mean absolute deviation as the normalization base.

Usage

rae(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. Constant observed series fail with 'hydroeval_metric_degeneracy' because the observed normalization denominator collapses to zero.

Value

Unnamed length-1 numeric value ('double') on success.

References

Draper, N. R., and H. Smith (1998). Applied Regression Analysis. 3rd ed. New York: John Wiley and Sons.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

rae(observed, simulated)

Spearman Rank Correlation Coefficient

Description

Compute Spearman rank correlation for paired simulated and observed values.

Usage

rho(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. Constant observed or simulated series fail with 'hydroeval_metric_degeneracy' because correlation is undefined.

Value

Unnamed length-1 numeric value ('double') on success.

References

Spearman, C. (1904). The Proof and Measurement of Association between Two Things. The American Journal of Psychology, 15(1), 72-101.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

rho(observed, simulated)

Root Mean Squared Error

Description

Compute root mean squared error between paired simulated and observed values.

Usage

rmse(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

'hydroeval' documents RMSE against Willmott and Matsuura (2005) as the approved methodological anchor for the current public residual-metric surface.

Invalid input fails with 'hydroeval_validation_error'. RMSE has no additional metric-specific degeneracy beyond the shared structural validation contract in the current approved public surface.

Value

Unnamed length-1 numeric value ('double') on success.

References

Willmott, C. J., and K. Matsuura (2005). Advantages of the Mean Absolute Error (MAE) over the Root Mean Square Error (RMSE) in Assessing Average Model Performance. Climate Research, 30(1), 79-82.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

rmse(observed, simulated)

Root Mean Squared Logarithmic Error

Description

Compute root mean squared logarithmic error using 'log1p' on both paired inputs.

Usage

rmsle(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. Any retained negative value in 'observed' or 'simulated' fails with 'hydroeval_metric_degeneracy'. 'hydroeval' cites Pedregosa et al. (2011) here as implementation-standard provenance, not as the original definitional source of RMSLE.

Value

Unnamed length-1 numeric value ('double') on success.

References

Pedregosa, F., G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay (2011). Scikit-learn: Machine Learning in Python. Journal of Machine Learning Research, 12, 2825-2830.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

rmsle(observed, simulated)

Root Relative Squared Error

Description

Compute root relative squared error using the observed centered sum of squares as the normalization base.

Usage

rrse(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. Constant observed series fail with 'hydroeval_metric_degeneracy' because the observed normalization denominator collapses to zero.

Value

Unnamed length-1 numeric value ('double') on success.

References

Draper, N. R., and H. Smith (1998). Applied Regression Analysis. 3rd ed. New York: John Wiley and Sons.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

rrse(observed, simulated)

Relative Standard Deviation

Description

Compute the standard-deviation ratio component 'sd(simulated) / sd(observed)'.

Usage

rsd(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. Constant observed series fail with 'hydroeval_metric_degeneracy'. This metric is a KGE component reference with ideal value 1.

Value

Unnamed length-1 numeric value ('double') on success.

References

Gupta, H. V., H. Kling, K. K. Yilmaz, and G. F. Martinez (2009). Decomposition of the Mean Squared Error and NSE Performance Criteria: Implications for Improving Hydrological Modelling. Journal of Hydrology, 377(1-2), 80-91.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

rsd(observed, simulated)

RMSE-Standard Deviation Ratio

Description

Compute the hydrologic RSR metric as 'rmse / sd(observed)'.

Usage

rsr(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. Constant observed series fail with 'hydroeval_metric_degeneracy'. This wrapper is the hydrologic RSR definition tied to Moriasi et al. (2007), not a generic normalized RMSE.

Value

Unnamed length-1 numeric value ('double') on success.

References

Moriasi, D. N., J. G. Arnold, M. W. Van Liew, R. L. Bingner, R. D. Harmel, and T. L. Veith (2007). Model Evaluation Guidelines for Systematic Quantification of Accuracy in Watershed Simulations. Transactions of the ASABE, 50(3), 885-900.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

rsr(observed, simulated)

Sum of Absolute Errors

Description

Compute 'sum(abs(simulated - observed))' for paired values.

Usage

sae(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. This metric has no additional metric-specific degeneracy beyond shared structural validation.

Value

Unnamed length-1 numeric value ('double') on success.

References

Draper, N. R., and H. Smith (1998). Applied Regression Analysis. 3rd ed. New York: John Wiley and Sons.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

sae(observed, simulated)

Symmetric Mean Absolute Percentage Error

Description

Compute symmetric mean absolute percentage error on a percent scale.

Usage

smape(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. For this approved implementation, a retained pair with 'observed = 0' and 'simulated = 0' contributes '0' to the average rather than causing omission or failure.

Value

Unnamed length-1 numeric value ('double') on success.

References

Hyndman, R. J., and A. B. Koehler (2006). Another Look at Measures of Forecast Accuracy. International Journal of Forecasting, 22(4), 679-688. doi:10.1016/j.ijforecast.2006.03.001.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

smape(observed, simulated)

Sum of Squared Errors

Description

Compute 'sum((simulated - observed)^2)' for paired values.

Usage

sse(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. This metric has no additional metric-specific degeneracy beyond shared structural validation.

Value

Unnamed length-1 numeric value ('double') on success.

References

Draper, N. R., and H. Smith (1998). Applied Regression Analysis. 3rd ed. New York: John Wiley and Sons.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

sse(observed, simulated)

Unbiased Root Mean Squared Error

Description

Compute unbiased RMSE after removing the mean of each paired series.

Usage

ubrmse(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. This metric has no additional metric-specific degeneracy beyond shared structural validation. The provenance for this metric is domain-standard rather than an original-source claim.

Value

Unnamed length-1 numeric value ('double') on success.

References

Entekhabi, D., E. G. Njoku, P. E. O'Neill, K. H. Kellogg, W. T. Crow, W. N. Edelstein, J. K. Entin, S. D. Goodman, T. J. Jackson, J. Johnson, J. Kimball, J. Piepmeier, R. D. Koster, N. Martin, K. C. McDonald, M. Moghaddam, S. Moran, R. Reichle, J.-C. Shi, M. W. Spencer, S. W. Thurman, L. Tsang, and J. Van Zyl (2010). The Soil Moisture Active Passive (SMAP) Mission. Proceedings of the IEEE, 98(5), 704-716.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

ubrmse(observed, simulated)

Volumetric Efficiency

Description

Compute volumetric efficiency as '1 - sum(abs(simulated - observed)) / sum(observed)'.

Usage

ve(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. A zero observed sum fails with 'hydroeval_metric_degeneracy'.

Value

Unnamed length-1 numeric value ('double') on success.

References

Criss, R. E., and W. E. Winston (2008). Do Nash Values Have Value? Discussion and Alternate Proposals. Hydrological Processes, 22(14), 2723-2725.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

ve(observed, simulated)

Weighted Absolute Percentage Error

Description

Compute weighted absolute percentage error on a percent scale.

Usage

wape(observed, simulated, na_policy = c("omit", "fail"))

Arguments

observed

Numeric vector of observed values.

simulated

Numeric vector of simulated values. Must have the same length as 'observed'.

na_policy

Character scalar controlling literal 'NA' handling. Use '"omit"' to remove paired 'NA' values before validation and computation, or '"fail"' to error if any paired 'NA' values are present.

Details

Invalid input fails with 'hydroeval_validation_error'. A zero absolute observed sum fails with 'hydroeval_metric_degeneracy'. 'hydroeval' cites Pedregosa et al. (2011) here as implementation-standard provenance, not as the original definitional source of WAPE.

Value

Unnamed length-1 numeric value ('double') on success.

References

Pedregosa, F., G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay (2011). Scikit-learn: Machine Learning in Python. Journal of Machine Learning Research, 12, 2825-2830.

Examples

observed <- c(1, 2, 3, 4)
simulated <- c(1.2, 1.9, 3.1, 3.8)

wape(observed, simulated)