lab4 is a package to handle linear regression models. It can handle functions such as print(), plot(), resid(), pred(), coef() and summary().
library(lab4)
The example below is to introduce how these functions work
linreg()
takes two parameter, Form : formula; data : a data.frame
linreg_mod <- linreg$new(Form = Petal.Length~Species, data=iris)
The print()
prints out the vector containing coefficients.
linreg_mod$print()
The plot()
plots such pictures(package ggplot2 is needed here)
linreg_mod$plot()
The resid()
returns the vector of residuals.
head(linreg_mod$resid())
The pred()
returns the predicted values.
head(linreg_mod$pred())
The coef()
returns the coefficients as a named vector.
linreg_mod$coef()
The summary()
returns a similar printout as printed for lm objects, but you only need to present
the coefficients with their standard error, t-value and p-value as well as the estimate of ˆσ and the degrees
of freedom in the model.
linreg_mod$summary()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.