crossval: Uses cross-validation to find a good weighting of...

Description Usage Arguments Details Value Examples

View source: R/crossval.R

Description

Uses cross-validation to find a good weighting of regularization

Usage

1
crossval(y, x, partitions = 5, degree = 1, lambda = c(0.1, 1, 10))

Arguments

y

Dependent variable

x

Independent variable(s) in array form

partitions

Number of partitions to divide the data into (n for n-fold validation)

degree

Degree of polynomial to fit

lambda

Vector of lambda weightings to try

Details

Splits the data into the number of partitions specified then attempts a fit on each partition, and calculates the error of the fit on the remaining data.

Value

A list of the the best lambda value, and its fit (includes coefficients and error).

Examples

1
crossval((1:10)^3, 1:10, partitions = 20, degree = 3, lambda = c(0.001, 0.01, 0.1, 1, 10))

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