NRnum: Solve a Systems of Nonlinear Equations Using the Newton's...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/lmfor.R

Description

Solves a system of equations of form f_1(x) = 0,f_2(x) = 0,...,f_p(x) = 0 for vector x using the multidimensional version of the Newton-Raphson algorithm. The gradients are solved numerically within the function using R-function numericDeriv.

Usage

1
NRnum(init, fnlist, crit = 6, ...)

Arguments

init

vector of initial values for x.

fnlist

list of R-functions for f_1(x), f_2(x), ..., f_p(x) each function gets a vector-valued argument x and returns a scalar value.

crit

Convergence criterion. Stop iteration when (|f_1(x)|+|f_2(x)|+...+|f_p(x)|<crit).

...

Other arguments passed to the functions of fnlist

Value

A list of components

par

the value of vector x in the solution

crit

the value of the convergence criterion at the solution

If estimation fails (no solution is found during 100 iterations), both elements of the solution are NA's.

Author(s)

Lauri Mehtatalo, <lauri.mehtatalo@uef.fi>

See Also

Function NR.

Examples

1
2
3
4
5
6
7
8
# Moment-based recovery of Weibull parameters
mu<-14
mu2<-210
muf<-function(theta) theta[2]*gamma(1+1/theta[1])-mu
mu2f<-function(theta) theta[2]^2*gamma(1+2/theta[1])-mu2
functions<-list(muf,mu2f)
momrec<-NRnum(c(3,13),functions)
momrec$par

Example output

Loading required package: stats4
Loading required package: nlme
Loading required package: spatstat
Loading required package: spatstat.data
Loading required package: rpart

spatstat 1.59-0       (nickname: 'J'ai omis les oeufs de caille') 
For an introduction to spatstat, type 'beginner' 


Note: R version 3.4.4 (2018-03-15) is more than 9 months old; we strongly recommend upgrading to the latest version
[1]  4.220147 15.398353

lmfor documentation built on July 8, 2020, 5:49 p.m.