Description Usage Arguments Details Value Author(s) References See Also Examples
Estimates coefficients of a linear regression model.
1 |
X |
|
y |
Numeric vector of length |
qr |
Logical.
If |
Calculates coefficients using the normal equation.
When that fails, QR decomposition is used when qr = TRUE
or singular value decomposition when qr = FALSE
.
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
Wikipedia: Singular value decomposition
Wikipedia: Orthogonal decomposition methods
Other beta-hat functions:
.betahatnorm()
,
.betahatqr()
,
.betahatsvd()
,
.intercepthat()
,
.slopeshatprime()
,
.slopeshat()
,
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"]]
betahat(X = X, y = y)
# Multiple regression----------------------------------------------
X <- jeksterslabRdatarepo::wages.matrix[["X"]]
# age is removed
X <- X[, -ncol(X)]
betahat(X = X, y = y)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.