Implementation of Lab 4 includes following tasks:

linreg function Implementation

Regrssions coefficients: $$\beta = (X^T X)^-1 X^Ty$$

The Fitted values: $$\ \hat y = X \beta$$

The residuals: $$\ \hat e = y - \hat y = y - X\beta$$

The degrees of freedom: $$~dy = n-p $$

The residual variance: $$ \sigma^2 = e^Te/~df $$

The variance of the regression coefficients: $$ Var(\beta) = \sigma^2/(X^T X)^1 $$

The t-values for each coefficients: $$ t~\beta~ = \beta/\sqrt Var(hat \beta) $$

Ploting Data using Graph

plot(Petal.Length~Species, data=iris)

Implementation of methods of class

The package includes following functions implementation: 1. print()

The print() prints the formula and the coefficients of the estimated linear regression model.
  1. plot()

    The plot() function uses ggplot2 to plot residuals vs. fitted values and the scale location. 3. resid()

    The resid() function returns a vector of the residuals of the estmated linear regression model. 4. pred()

    The pred() function returns a vector of the predicted values of the estimated linear regression model. 5. coef()

    The coef() function returns the coefficients of the estimated linear regression model. 6. summary()

    The summary() function returns the coefficients, standard errors, t-values and p-values of the estimated linear regression model.



ugurcanlacin/Lab7 documentation built on May 24, 2019, 7:26 p.m.