sum_squares: Sum of Squared Error

Description Usage Arguments Details Value Examples

View source: R/orthogonal.R

Description

Sum of Squared Error

Usage

1
sum_squares(x, y = x)

Arguments

x

numeric vector

y

optional, numeric vector, same length as x

Details

The sum of squared errors for a length n vector x will equal

S_{xx} = ∑_i^n(x - \overline{x})^2,

where \overline{x} is the mean of x.

The cross-product is

S_{xy} = ∑_i^n (x - \overline{x})(y - \overline{y})

Value

either the sum of squared errors for x (if y is left out), or the cross-product of two vectors x with y

Examples

1
2
3
4
5
6
7
# the sum of squared errors for x
x <- rnorm(10)
sum_squares(x)

# a cross-product
y <- rnorm(10)
sum_squares(x, y)

psadil/nmmr documentation built on June 13, 2021, 11:42 a.m.