reg.lm: Fits a polynomial of specified degree to the data with a...

Description Usage Arguments Details Value Examples

View source: R/regfit.R

Description

Fits a polynomial of specified degree to the data with a regularization term

Usage

1
reg.lm(y, x, degree = 1, lambda = 1)

Arguments

y

Dependent variable

x

Independent variable(s) in array form

degree

Degree of polynomial to fit

lambda

Weight of regularization term (may be selected using crossval)

Details

Finds the polynomial of specified degree that minimizes

({y}-p({x}))^2+lambda*sum(coeff^2)

Where p is the polynomial and coeff is its coefficients.

This function is useful when concerns about overfitting are present. lambda may be chosen by the crossval function.

Value

List with the coefficients for each term in the polynomial and the error.

Examples

1
reg.lm((1:10)^3, 1:10, degree = 3, lambda = 1)

arsbar24/reg-fit documentation built on May 14, 2019, 2 a.m.