nega_gra: Function that calculate the negative gradient of given loss...

Description Usage Arguments Value Examples

View source: R/gradient_boosting.R

Description

Function that calculate the negative gradient of given loss function

Usage

1
nega_gra(loss, x, y, coef, eps = 0.001)

Arguments

loss

- the loss function used

x

- input independent variables x for the training

y

- the true dependent variable

coef

- the estimate of the coefficients in regression

eps

- the small increase used in the calculation of gradient

Value

The negative gradient value of the given loss function.

Examples

1
2
3
4
5
6
x <- matrix(rnorm(4000), 200, 20)
beta <- rnorm(5)
y <- x[, 1:length(beta)] %*% beta + rnorm(200)
coef <- lm(y ~ -1 + x)$coefficients
loss <- mse
nega_gra(loss, x, y, coef)

StevenBoys/Ensemblelearn documentation built on Dec. 11, 2019, 2:06 a.m.