knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(lab4linreg)
lab4linreg package contains linreg class. The aim of this package is to compute linear regression models.
linreg class takes as inputs: a formula and a data.frame and returns an object of class linreg. On initialization the linreg object calculates regression coefficients, fitted values, residuals, degrees of freedom, residual variance, the variance of the regression coefficiients as well as the t-values for each of those coefficients.
several methods are implement to return the calculated elements:
the print() prints the object call and the calculated regression coefficients.
the plot() plots the residuals with respect to the fitted values and plots the standardized residuals with respect to the fitted values.
the resid() returns the vector containing the residual values.
the pred() returns the prediction of the fitted values.
the coef() returns the coefficients of the linear regression.
the summary() prints a summary of the linear regression model containing the estimated coefficients, standard error, t-values, p-values and significance levels. It also prints the residual standard error as well as the degree of freedom.
create an object of class linreg
data(iris) linreg_obj = linreg(Petal.Length~Species, iris)
call print method
linreg_obj$print()
call plot method
linreg_obj$plot()
call resid method
linreg_obj$resid()
call pred method
linreg_obj$pred()
call coef method
linreg_obj$coef()
call summary method
linreg_obj$summary()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.