Calculates the R-square value for objects of class nls, lm, glm, drc
or any other models from which fitted and residuals can be extracted.
Since version 1.2-9 it calculates a weighted R-square if the object has an item object$weights containing weighting values.
Usage
Rsq(object)
Arguments
object
a fitted model.
Value
The R-square value of the fit.
Details
Uses the most general definition of R-square: $$R^2 \equiv 1 - \frac{RSS}{TSS}$$ where
$$RSS = \sum_{i=1}^{n}w_i \cdot (y_i-\hat{y_i})^2$$ and $$TSS = \sum_{i=1}^{n}w_i \cdot (y_i - \bar{y})^2$$
using the weighted mean $$\bar{y} = \frac{\sum_{i=1}^{n}w_ix_i}{\sum_{i=1}^{n}w_i}$$