Description Usage Arguments Value Author(s) References See Also Examples
Estimates coefficients of a linear regression model using
\boldsymbol{\hat{β}} = ≤ft( \mathbf{X}^{T} \mathbf{X} \right)^{-1} ≤ft( \mathbf{X}^{T} \mathbf{y} \right) .
Also know as the normal equation.
1 | .betahatnorm(X, y)
|
X |
|
y |
Numeric vector of length |
Returns \boldsymbol{\hat{β}}, that is, a k \times 1 vector of estimates of k unknown regression coefficients estimated using ordinary least squares.
Ivan Jacob Agaloos Pesigan
Wikipedia: Ordinary least squares
Wikipedia: Inverting the matrix of the normal equations
Other beta-hat functions:
.betahatqr()
,
.betahatsvd()
,
.intercepthat()
,
.slopeshatprime()
,
.slopeshat()
,
betahat()
,
intercepthat()
,
slopeshatprime()
,
slopeshat()
1 2 3 4 5 6 7 8 9 10 11 | # Simple regression------------------------------------------------
X <- jeksterslabRdatarepo::wages.matrix[["X"]]
X <- X[, c(1, ncol(X))]
y <- jeksterslabRdatarepo::wages.matrix[["y"]]
.betahatnorm(X = X, y = y)
# Multiple regression----------------------------------------------
X <- jeksterslabRdatarepo::wages.matrix[["X"]]
# age is removed
X <- X[, -ncol(X)]
.betahatnorm(X = X, y = y)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.