knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(ggplot2) library(gridExtra) library(grid) library(lab4group8)
This package provides a Linear Regression Model as a function that returns the model as an Object.
To run the model you need to input a formula and a dataset. This example uses the dataset iris, which is standard include in R.
data(iris)
The model is of the form y~x, where y is the Sepal length depending on the x, the petal length.
linreg1 <- linreg(Sepal.Length~Petal.Length, data = iris)
In the command above we create an object of the class linreg which contains all the information that we need.
The linreg object can be manipulated by using six different methods:
linreg1$print() prints the coefficients.
linreg1$print()
linreg1$plot() plots two graphs. The first plots the Residuals vs the Fitted values. The second is a Scale-Locationo plot.
linreg1$plot()
linreg1$resid() returns a vector with the residuals.
head(linreg1$resid())
linreg1$pred() returns a vector with the predicted values.
head(linreg1$pred())
linreg1$coef() returns the intercept plus the coefficients.
linreg1$coef()
linreg1$summary() prints the coefficients with their standard error, t-values, and p-value, plus the estimate of standard deviation of the variance and the degrees of freedom.
linreg1$summary()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.