gradient_descent_OLS_cv: A function fitting the OLS model

Description Usage Arguments Examples

View source: R/cv-gradient-descent.r

Description

This is a function fitting the OLS model using gradient descent that calculates the penalty based on the out-of-sample accuracy. Here we use cross validation to calculate the out-of-sample accracy.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
gradient_descent_OLS_cv(
  formula,
  data_frame,
  nfolds = 10,
  contrasts = NULL,
  lambda = 1e-04,
  tolerence = 1e-20,
  beta1 = 1,
  max_itr = 1e+06
)

Arguments

formula

a formula of linear model

data_frame

a data_frame

nfolds

Default is 10. the number of folds for cross validation

contrasts

Default is NULL. a list of constasts for factor variables

lambda

Default is 0.0001. The speed of gradient descent

tolerence

Default is 1e-20. The minimum difference between the old ssr and the update ssr.

beta1

Default is 1. The initial value of beta.

max_itr

Default is 1e6. The maximum number of iterations

Examples

1
2
data(iris)
gradient_descent_OLS_cv(Sepal.Length ~ ., iris,nfolds=10)

cz354/bis557 documentation built on Dec. 20, 2020, 3:05 a.m.