knitr::opts_chunk$set(collapse = TRUE, comment = "#>", message = FALSE)
This package has been built to fit linear models by running regression using least squares. The package code is designed to work with popular data sets such as 'iris'. This vignette will document different examples to showcase how this package can be used.
The most important function around which this package is built is the linreg() function. It takes 2 inputs - formula and data containing the independent and dependent variables for modelling. Note that the input for formula is a formula data type.
library(Group8LinearRegressionFJ) data("iris") model <- linreg(Petal.Length ~ Species, iris)
The output of the linreg() function is stored in an object of linreg data type
Given that the output of linreg() is stored in a new s3 class, the package includes various functions with linreg methods that will help the user evaluate the results of linear modelling. Next we explore each of these methods.
The print() method takes the object of class linreg where the output of the modelling is stored. It prints out the coefficients and coefficient names along with the call.
print(model)
The plot() generates 2 plots for the model
plot(model)
The resid() displays the vector of the residuals in the model
resid(model)
The pred() returns the predicted values in the model
pred(model)
The coef() returns the coefficients in the model as a named vector
coef(model)
The summary() displays the most important statistic results of the model i.e. coefficients, standard error, t-values, p-values, variance of coefficients and the degrees of freedom in the model
summary(model)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.