Skip to contents

Hastie, Tibshirani and Friedman (2009), The Elements of Statistical Learning, 2nd ed., Springer, Section 2.4, book pp. 18-19 (PDF pp. 37-38).

Usage

Epetheor(X, y)

Arguments

X

N-by-p matrix of inputs.

y

N-vector of responses.

Value

list: estimate, beta, exx, exy, epe, eyy, n, p, method.

Details

EPE(f) = E(Y - f(X))^2 (2.9) and beta = [E(XX')]^-1 E(XY) (2.16), the latter obtained by plugging the linear model (2.15) into (2.9) and differentiating. (2.16) is a population statement; the sample moment matrices (1/N) X'X and (1/N) X'y are substituted here, which is exactly the identification the book makes on p. 19 between (2.16) and (2.6).

No intercept is added: (2.16) has none. Supply a constant column in X.

Examples

Epetheor(cbind(rep(1, 4), c(1, 2, 3, 4)), c(2, 4, 6, 8))$beta
#> [1] 0 2