linear_gd_optim: Linear Gradient Descend

Description Usage Arguments Value Examples

View source: R/linear_gd_optim.R

Description

This function computes the vector of parameters in a linear regression model via the Gradient Descend Method.

Usage

1
linear_gd_optim(b_pre, X, y, tol = 0.001, maxit = 1000, stepsize = 0.001)

Arguments

b_pre

vector of initial parameters

X

Covariates Matrix: each column contains observations for each covariate.

y

Response variable observations

tol

Tolerance level for the optimization process, the default is 0.001.

maxit

Maximum iterations number

stepsize

The value for the stepsize in the equation of the gradient descend

Value

A list containing the fitted values for the beta vector and the number of iterations performed

Examples

1
2
3
4
5
6
7
8
set.seed(8675309)
n = 1000
x1 = rnorm(n)
x2 = rnorm(n)
y = 1 + .5*x1 + .2*x2 + rnorm(n)
X=cbind(x1,x2)
b_pre=c(0,0,0)
linear_gd_optim(b_pre,X,y)

FedericoCortese/R4DScm documentation built on July 12, 2021, 5:30 a.m.