knitr::opts_chunk$set( collapse = TRUE, comment = "#>", echo = TRUE )
library(ggplot2) library(linear.regression)
This package uses a linear regression model. It uses linear algebra to give a linear regresion model functionality when given a formula and a dataframe to work with. for the following examples the dataset iris
will be used.
linreg_mod = linreg$new(Petal.Length~Sepal.Width+Sepal.Length, data=iris)
A method call that gives back the formula along with the coeficients.
linreg_mod$print()
This one method call returns two plots containning the residuals in relation to the fitted values. the first one gives the Residuals vs Fitted, while the seccond one gives the Scale - Location.
linreg_mod$plot()
A method to call on the residuals
$$\hat{e} = y - \hat{y} = y - X\hat{\beta}$$
head(linreg_mod$resid())
A method call to get the predicted values $\hat{y}$.
head(linreg_mod$pred())
A method call to get the coefficients as a named vector.
$$\hat{\beta} = (X^TX)^{-1}X^Ty$$
linreg_mod$coef()
This returns a printout presenting the coefficients with their standard error, t-value and p-value as well as the estimate of $\hat{\sigma}$ along with the degrees of freedom in the model.
linreg_mod$summary()
Matrix decompositions for regression analysis
Some Notes on Least Squares, QR-factorization, SVD and Fitting
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.