Description Usage Arguments Value Author(s) References See Also Examples
Calculates residuals using
\hat{\varepsilon}_{i} = Y_{i} - \hat{Y}_{i} \\ = Y_{i} - ≤ft( \hat{β}_{1} + \hat{β}_{2} X_{2i} + \hat{β}_{3} X_{3i} + … + \hat{β}_{k} X_{ki} \right) \\ = Y_{i} - \hat{β}_{1} - \hat{β}_{2} X_{2i} - \hat{β}_{3} X_{3i} - … - \hat{β}_{k} X_{ki} .
In matrix form
\boldsymbol{\hat{\varepsilon}} = \mathbf{y} - \mathbf{\hat{y}} \\ = \mathbf{y} - \mathbf{X} \boldsymbol{\hat{β}} .
1 | yminusyhat(X, y)
|
X |
|
y |
Numeric vector of length |
Returns an n \times 1 matrix of residuals ≤ft( \boldsymbol{\hat{\varepsilon}} \right), that is, the difference between the observed ≤ft( \mathbf{y} \right) and predicted ≤ft( \mathbf{\hat{y}} \right) values of the regressand variable ≤ft( \boldsymbol{\hat{\varepsilon}} = \mathbf{y} - \mathbf{\hat{y}} \right).
Ivan Jacob Agaloos Pesigan
Wikipedia: Errors and Residuals
Other residuals functions:
.My()
,
.tepsilonhat()
,
.yminusyhat()
,
My()
,
epsilonhat()
,
tepsilonhat()
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.