newton_raph: Multivariate Newton-Raphson fitting method

Description Usage Arguments Value Examples

View source: R/newton_raph.R

Description

newton_raph provides an environment for performing iterated Newton Raphson root finding of multivariate functions with an optional Backtracking line search, For more on line search see: http://cosmos.phy.tufts.edu/~danilo/AST16/Material/RootFinding.pdf page479

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
newton_raph(
  vec_J,
  par0,
  ...,
  LSearch = FALSE,
  w = rep.int(1, length(par0)),
  Max.it = 2000,
  prec = 1e-05,
  step.scale = 1
)

Arguments

vec_J

a function which returns newton-raphson steps via $step and the functions via $vec

par0

Initial values for the parameters to be optimized over.

...

Further arguments to be passed to vec_J

LSearch

Option to perform the Backtracking line search algorithm. Defaults to FALSE

w

Weights for Backtracking algorithm. Must be non-negative with length equal to length(par0)

Max.it

Maximum number of iterations (Function calls)

prec

Parameter precision tolerance. Iteration will stop when the step is smaller than the precision for all parameters.

step.scale

Optional scaling step to perform damped Newton Raphson.

Value

A list containing the par estimates and an evaluation of the vec_J function at these parameters.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#Optimisation of the function f(x,y) = (x*exp(y) - 1, -1-x^2 + y)
vec_J <- function(par){
    x=par[1]
    y=par[2]
    f = c(x*exp(y) - 1, -1-x^2 + y)
    fdash = matrix(c(exp(y),-2*x,x*exp(y),1),ncol=2)
    step = solve(fdash,f)
    return(list(step=step, vec=f))
}

newton_raph(vec_J,par0=c(0,0))

ohines/plmed documentation built on Jan. 9, 2021, 11:59 a.m.