pastas.stats.metrics.pearsonr#

pearsonr(obs, sim, missing='drop', weighted=False, max_gap=30)[source]#

Compute the (weighted) Pearson correlation (r).

Parameters:
  • sim (pandas.Series) – The Series with the simulated values.

  • obs (pandas.Series) – The Series with the observed values.

  • missing (str, optional) – string with the rule to deal with missing values in the observed series. Only “drop” is supported now.

  • weighted (bool, optional) – Weight the values by the normalized time step to account for irregular time series. Default is False.

  • max_gap (int, optional) – maximum allowed gap period in days to use for the computation of the weights. All time steps larger than max_gap are replace with the max_gap value. Default value is 30 days.

Return type:

float

Notes

The Pearson correlation (r) is computed as follows:

\[r = \frac{\sum_{i=1}^{N}w_i (x_i - \bar{x})(y_i - \bar{y})} {\sqrt{\sum_{i=1}^{N} w_i(x_i-\bar{x})^2 \sum_{i=1}^{N} w_i(y_i-\bar{y})^2}}\]

Where \(x\) is observed time series, \(y\) the simulated time series, and \(N\) the number of observations in the observed time series.