knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Linear Regression with linreg

Here is how we can perform a linear regression analysis with the linreg. Let's begin by using a well-known example, the iris dataset.

library(lab4elife599carde734)
data("iris")
my_linreg_object = linreg(Petal.Length ~ Species, data = iris)

Upon instantiation, the object my_linreg_object of class linreg performs all calculations necessary and end up containing values of important variables, such as the estimated coefficients and regression statistics.

An overview of the information that defines the object, together with the estimted coefficients, can be obtained by:

my_linreg_object$print()

A summary of the statistics related to the regression process are available by:

my_linreg_object$summary()

Residuals, predicted dependent variables and coefficients can be directly accessed respectively by resid(), pred() and coef(), as explored below:

head(my_linreg_object$resid())
head(my_linreg_object$pred())
my_linreg_object$coef()

Using the method plot(), we can observe residuals and the square root of absolute values of standardized residuals plotted against the fitted values:

my_linreg_object$plot()


Efaq/lab4elife599carde734 documentation built on Dec. 17, 2021, 6:23 p.m.