new_gradient_descent: New Gradient Descent

Description Usage Arguments Value Examples

View source: R/new-gradient-descent.R

Description

This is a function fitting the OLS model using gradient descent which calculate the loss based on the out-of-sample accuracy.

Usage

1
2
new_gradient_descent(form, data, gamma = 1e-04, beta0 = 1,
  fold.num = 10, stop.diff = 1e-08, max.itera = 5e+05)

Arguments

form

a formula with the legal format.

data

a dataframe provided by the user.

gamma

a factor defined by user as a pace or speed of gradient descent (default=0.0001).

beta0

an initializer for the beta vector that can be changed by user (default=1).

fold.num

a fold number of k-fold cv.

stop.diff

an absolute difference between loss and the updated one set by user to stop the iteration at some satisfying point (default=1e-8).

max.itera

a maximum number of iterations set by user, which is an alternative criterion to stop the iterations (default=1e6).

Value

a list including the coefficient estimates.

Examples

1
2
3
data(iris)
fit <- new_gradient_descent(Sepal.Length ~ ., iris)
fit$coefficients

BillyTian/bis557 documentation built on Dec. 19, 2020, 7:30 a.m.