pastas.stats.metrics.rsq ======================== .. py:function:: pastas.stats.metrics.rsq(obs: pandas.Series, sim: pandas.Series | None = None, res: pandas.Series | None = None, missing: str = 'drop', weighted: bool = False, max_gap: int = 30, nparam: int | None = None) -> float Compute R-squared, possibly adjusted for the number of free parameters. :param obs: Series with the observed values. :type obs: pandas.Series :param sim: The Series with the simulated values. :type sim: pandas.Series, optional :param res: 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. :type res: pandas.Series, optional :param missing: string with the rule to deal with missing values. Only "drop" is supported now. :type missing: str, optional :param weighted: If weighted is True, the variances are computed using the time step between observations as weights. Default is False. :type weighted: bool, optional :param max_gap: 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. :type max_gap: int, optional :param nparam: number of calibrated parameters. :type nparam: int, optional .. rubric:: Notes .. math:: \rho_{adj} = 1- \frac{n-1}{n-n_{param}}*\frac{rss}{tss} Where n is the number of observations, :math:`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 :math:`\rho` is adjusted for the number of calibration parameters. .. !! processed by numpydoc !!