Calculates the total sum of squares \(\left( \mathrm{TSS} \right)\) using $$ \mathrm{TSS} = \sum_{i = 1}^{n} \left( Y_i - \bar{Y} \right)^2 \\ = \sum_{i = 1}^{n} Y_{i}^{2} - n \bar{Y}^2 $$ In matrix form $$ \mathrm{TSS} = \sum_{i = 1}^{n} \left( \mathbf{y} - \mathbf{\bar{y}} \right)^2 $$ Equivalent computational matrix formula $$ \mathrm{TSS} = \mathbf{y}^{\prime} \mathbf{y} - n \mathbf{\bar{Y}}^{2}. $$ Note that $$ \mathrm{TSS} = \mathrm{ESS} + \mathrm{RSS} . $$

TSS(y)

Arguments

y

Numeric vector of length n or n by 1 matrix. The vector \(\mathbf{y}\) is an \(n \times 1\) vector of observations on the regressand variable.

Value

Returns the total sum of squares \(\left( \mathrm{TSS} \right)\).

References

Wikipedia: Residual Sum of Squares

Wikipedia: Explained Sum of Squares

Wikipedia: Total Sum of Squares

Wikipedia: Coefficient of Determination

See also

Other sum of squares functions: .ESS(), .RSS(), ESS(), RSS()

Author

Ivan Jacob Agaloos Pesigan

Examples

y <- jeksterslabRdatarepo::wages.matrix[["y"]] TSS(y = y)
#> [1] 80309.82