Description Details Author(s) References Examples
The function linreg
takes a formula object and a
data.frame
as arguments, and returns an object as an S3 class.
It performs ordinary least squares or QR decomposition to calculate different statistics.
A linear regression model is fitted by using the linreg
function, which returns an object of an S3 class. It calculates the coefficient estimates and the variance of the estimates using ordinary least squares (OLS) if QR = FALSE
. QR decomposition is used instead if QR = TRUE
.
The arguments take a formula on the form y ~ x and a data.frame
of arbitrary size containing numeric variables in the columns.
Sofie Jörgensen, Henrik Olofsson
Maintainer: Sofie Jörgensen <sofjo281@student.liu.se>, Henrik Olofsson <henol528@student.liu.se>
https://en.wikipedia.org/wiki/QR_decomposition
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # Example data
data(mtcars)
# Fitting a linear regression model using OLS
model_ols <- linreg(formula = mpg ~ wt + cyl, data = mtcars, QR = FALSE)
# Fitting a linear regression model using QR decomposition
model_qr <- linreg(formula = mpg ~ wt + cyl, data = mtcars, QR = TRUE)
# Result
print(model_qr)
plot(model_qr)
resid(model_qr)
pred(model_qr)
coef(model_qr)
summary(model_qr)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.