ridgereg-class: A reference class generator for ridge regression

Description Details Fields Methods References Examples

Description

This function creates a class ridgereg object which does ridge regression upon a specified formula and data.frame and parameter lambda. Ridge regression is performed by QR decompsition. Plots are handled by packages ggplot2, grid and gridExtra.

Details

This RC class generator can create a ridgereg object from any formula as long as the response are not factors. The QR decomposition calculations are all done using matrices. The printouts are simple paste and writeLines calls for the most part, and are not objects. Every method returns something relevant.

Fields

formula

A formula taken as input, upon which linear regression is performed.

data

A data.frame which has names to which the names in the formula refer.

dataname

A character string containing the name of the data.

lambda

A numeric scalar which specifies the hyperparameter lambda

coefficients

A single column matrix consisting of the calculated regression coefficients of the linear model.

predicted

A vector containing the linearly predicted response.

Methods

coef()

Returns a named vector of the regression coefficients in the linear model.

initialize(formula, data, lambda)

From inputs formula and data, generates all the other fields upon object initialization.

predict(newframe = NULL)

Returns the predicted values of the linear model. Can also take a new data.frame with covariate values and make new prediction based on them.

print()

Gives a printout of the call as well as the calculated regression coefficients.

References

http://en.wikipedia.org/wiki/Tikhonov_regularization

Examples

1
2
3
data(faithful)
ridgeobject <- ridgereg(formula = eruptions ~ waiting, data = faithful,lambda = 5)
ridgeobject$print()

thozh912/Lab7 documentation built on May 31, 2019, 11:18 a.m.