Learn R Programming

optR (version 1.2.5)

cgm: Optimization & estimation based on Conjugate Gradient Method

Description

Function utilizes the Conjugate Gradient Method for optimization to solve equation Ax=b

Usage

cgm(A, b, x = NULL, iter = 500, tol = 1e-07)

Arguments

A
: Input matrix
b
: Response vector
x
: Initial solutions
iter
: Number of Iterations
tol
: Convergence tolerance

Value

optimal : Optimal solutionsinitial : initial solutionitr.conv : Number of iterations for convergenceconv : Convergence array

Examples

Run this code
A<-matrix(c(4,-1,1, -1,4,-2,1,-2,4), nrow=3,ncol=3, byrow = TRUE)
b<-matrix(c(12,-1, 5), nrow=3,ncol=1,byrow=TRUE)
Z<-optR(A, b, method="cgm", iter=500, tol=1e-7)

Run the code above in your browser using DataLab