The default behavior for adding and solving with noisemodels has changed from Pastas 1.5. Find more information here


rsq(obs, sim=None, res=None, missing='drop', weighted=False, max_gap=30, nparam=None)[source]#

Compute R-squared, possibly adjusted for the number of free parameters.

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

  • sim (pandas.Series, optional) – The Series with the simulated values.

  • res (pandas.Series, optional) – The Series with the residual values. If time series for the residuals are provided, the sim and obs arguments are ignored. Note that the residuals must be computed as obs - sim here.

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

  • weighted (bool, optional) – If weighted is True, the variances are computed using the time step between observations as weights. 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.

  • nparam (int, optional) – number of calibrated parameters.

Return type



\[\rho_{adj} = 1- \frac{n-1}{n-n_{param}}*\frac{rss}{tss}\]

Where n is the number of observations, \(n_{param}\) the number of free parameters, rss the sum of the squared errors, and tss the total sum of squared errors.

When nparam is provided, the \(\rho\) is adjusted for the number of calibration parameters.