library(assignment4Package)

Linreg Reference Class Object

Linreg class requires two arguments: formula and data, and it calculate Regressions coefficient, fitted values, residuals, degrees of freedom, and residual variance of multiple regression model.

print()

This function should print out the coefficients and coefficient names, similar as done by the lm class.

data(iris)
l1<-linreg$new(Petal.Length~Species, data=iris)

l1$print()

plot()

data(iris)
l1<-linreg$new(Petal.Length~Species, data=iris)

l1$plot()

resid()

This function should return the vector of residuals.

data(iris)
l1<-linreg$new(Petal.Length~Species, data=iris)

l1$resid()

pred()

This function should return the predicted values.

data(iris)
l1<-linreg$new(Petal.Length~Species, data=iris)

l1$pred()

coef()

This function should return the coefficients as a named vector.

data(iris)
l1<-linreg$new(Petal.Length~Species, data=iris)

l1$coef()

summary()

This function should return 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.

data(iris)
l1<-linreg$new(Petal.Length~Species, data=iris)

l1$summary()

* Linreg_qr Reference Class Object

Linreg_qr class has the same function with Linreg class, but using QR Decomposition.



kelly-ly/LAB-4 documentation built on Nov. 4, 2019, 3:46 p.m.