R/epsilonhat.R
yminusyhat.Rd
Calculates residuals using $$ \hat{\varepsilon}_{i} = Y_{i} - \hat{Y}_{i} \\ = Y_{i} - \left( \hat{\beta}_{1} + \hat{\beta}_{2} X_{2i} + \hat{\beta}_{3} X_{3i} + \dots + \hat{\beta}_{k} X_{ki} \right) \\ = Y_{i} - \hat{\beta}_{1} - \hat{\beta}_{2} X_{2i} - \hat{\beta}_{3} X_{3i} - \dots - \hat{\beta}_{k} X_{ki} . $$ In matrix form $$ \boldsymbol{\hat{\varepsilon}} = \mathbf{y} - \mathbf{\hat{y}} \\ = \mathbf{y} - \mathbf{X} \boldsymbol{\hat{\beta}} . $$
yminusyhat(X, y)
X |
|
---|---|
y | Numeric vector of length |
Returns an \(n \times 1\) matrix of residuals \(\left( \boldsymbol{\hat{\varepsilon}} \right)\), that is, the difference between the observed \(\left( \mathbf{y} \right)\) and predicted \(\left( \mathbf{\hat{y}} \right)\) values of the regressand variable \(\left( \boldsymbol{\hat{\varepsilon}} = \mathbf{y} - \mathbf{\hat{y}} \right)\).
Wikipedia: Errors and Residuals
Other residuals functions:
.My()
,
.tepsilonhat()
,
.yminusyhat()
,
My()
,
epsilonhat()
,
tepsilonhat()
Ivan Jacob Agaloos Pesigan
# Simple regression------------------------------------------------ X <- jeksterslabRdatarepo::wages.matrix[["X"]] X <- X[, c(1, ncol(X))] y <- jeksterslabRdatarepo::wages.matrix[["y"]] epsilonhat <- yminusyhat(X = X, y = y) hist(epsilonhat)# Multiple regression---------------------------------------------- X <- jeksterslabRdatarepo::wages.matrix[["X"]] # age is removed X <- X[, -ncol(X)] epsilonhat <- yminusyhat(X = X, y = y) hist(epsilonhat)