genD(func, x, method="Richardson",
method.args=list(), ...)
## S3 method for class 'default':
genD(func, x, method="Richardson",
method.args=list(eps=1e-4, d=0.0001,
zero.tol=sqrt(.Machine$double.eps/7e-7), r=4, v=2), ...)
func
."Richardson"
or "simple"
indicating
the method to use for the aproximation.grad
.
(Arguments not specified remain with their default values.)func
.
WARNING: None of these should have names matching other arguments of this function.D
is a matrix of first and second order partial
derivatives organized in the same manner as Bates and
Watts, the number of rows is equal to the length of the result of
func
, the first p columns are the Jacobian, and the
next p(p+1)/2 columns are the lower triangle of the second derivative
(which is the Hessian for a scalar valued func
).
p
is the length of x
(dimension of the parameter space).
f0
is the function value at the point where the matrix D
was calculated.
The genD
arguments func
, x
, d
, method
,
and method.args
also are returned in the list.func
at the point x
.
For a scalar valued function these are the gradient vector and
Hessian matrix. (See grad
and hessian
.)
For a vector valued function the first derivative is the Jacobian matrix
(see jacobian
). See grad
for more details on the Richardson's extrapolation parameters. The the first order derivative with respect to $x_i$ is
$$f'_{i}(x) =
The second order derivative with respect to $x_i$ is
$$f''_{i}(x) =
The second order derivative with respect to $x_i, x_j$ is
$$f''_{i,j}(x) = $$f(x_{1},\dots,x_{i}-d,\dots,x_{j}-d,\dots,x_{n})>/(2*d^2) -
(f''_{i}(x) + f''_{j}(x))/2$$
Bates, D.M. and Watts, D. (1988) "Non-linear Regression Analysis and Its Applications." Wiley.
hessian
,
grad
func <- function(x){c(x[1], x[1], x[2]^2)}
z <- genD(func, c(2,2,5))
Run the code above in your browser using DataLab