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

Importing the library:

library(lab4Rpackage)

Fitting a model:

In order to fit a model, use the linereg(). The function has two arguments: formula and data. The function linereg() returns a linreg object.

data(iris)
obj <- linreg(formula = Petal.Length~Species, data = iris)

Methods

Print

Print() will return the function call as well as the estimated $\beta$-coefficients in the model.

print(obj)

coef

coef() will return $\beta$-coefficients in the model.

coef(obj)

plot

plot() returns two scatter plots. The first one shows the residual against fitted values. The second scatter plot shows square root of the absolute value of the standardized residuals against the fitted values.

plot(obj)

pred

pred() returns the fitted values in the estimated model.

head(pred(obj),10)

resid

resid() returns the residuals in the estimated model.

head(resid(obj))

summary

summary() returns summary statistics about the estimated coefficient such as estimated parameters, the estimated standard error, t-value and p-value. It also returns the variance in the estimated model and the degree of freedom.

summary(obj)


linuskage2021/lab4Rpackage documentation built on Dec. 21, 2021, 10:51 a.m.