ridgereg: Ridge Regression

Description Usage Arguments Details Value Note See Also Examples

View source: R/ridgereg.R

Description

The 'ridgereg' function runs a ridge regression algorithm on a collection of observations of a dependent variable and corresponding independent variables. Thereafter, it provides views of regression coefficients, residuals, and other statistics

Usage

1
ridgereg(formula, data, lambda, qr_method = FALSE, ...)

Arguments

formula

an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. The details of model specification are given under ‘Details’.

data

a data frame containing the variables in the model

lambda

hyperparameter for ridge regression

qr_method

a boolean; TRUE forces ridgereg to use QR decomposition for the regression

...

additional arguments to be passed to the model.matrix function, see 'Details'

Details

Models for linreg are specified symbolically. A typical model has the form response ~ terms or response ~ ., where 'response' is the (numeric) response vector. In the former form, 'terms' is a series of terms which specifies a linear predictor for response. In the latter form, the '.' indicates that all available predictors must be taken into account for modelling. Term specification of the form first + second indicates all the terms in first together with all the terms in second with duplicate terms removed. Specifications of the form first:second or first*second are recognised exactly the same way as first+second. Additional arguments passed via ..., if provided, will force the linear model will have no intercept.

Value

the function returns an object of class "ridgereg", which has a number of associated methods including print.ridgereg, predict.ridgereg, and coef.ridgereg. The "ridgereg" object itself is a list containing at least the following components:

call

the matched call

coefficients

a named vector of coefficients

fitted_values

the fitted mean values

residuals

the residuals, that is response minus fitted values

df

the residual degrees of freedom

residual_variance

estimated value of the variance of the residuals

t_values

t-statistics of the independent variables, that is coefficients/standard-error

p_values

p-values for the two-sided t-test with null that coefficients are each zero

std_means

a vector of means of the independent variables in the training dataset

std_sd

a vector of standard deviations of the independent variables in the training dataset

Note

The 'ridgereg' function was designed to work like the 'lm.ridge' function in the 'MASS' package. Independent variables are standardised before regression is performed; the predict method on the returned object will use the same means and standard deviations used for standardisation of the training dataset. Review the 'See Also' section.

See Also

lm.ridge

lm

Examples

1
2
3
library(mlbench)
data(BostonHousing)
ridgereg(medv ~ crim + zn + indus + chas + nox + rm + age + dis + rad, BostonHousing, lambda = 1)

dsn00b/linear_regression documentation built on Nov. 9, 2021, 11:39 p.m.