pastas.stats.metrics.pearsonr#
- pastas.stats.metrics.pearsonr(obs: pandas.Series, sim: pandas.Series, missing: str = 'drop', weighted: bool = False, max_gap: int = 30, **kwargs) float#
Compute the (weighted) Pearson correlation (r).
- Parameters:
obs (pandas.Series) – The Series with the observed values.
sim (pandas.Series) – The Series with the simulated 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.
Notes
The Pearson correlation (r) is computed as follows:
\[\begin{split}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}}\end{split}\]Where \(y_o\) is observed time series, \(y_s\) the simulated time series, and \(N\) the number of observations in the observed time series.