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 (y_{o,i} - \bar{y_o})(y_{s,i} - \bar{ y_s})} {\sqrt{\sum_{i=1}^{N} w_i(y_{o,i}-\bar{y_o})^2 \sum_{i=1}^{N}w_i( y_{s,i} -\bar{y_s})^2}}\]

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