Description Usage Arguments Details Value Author(s) See Also Examples

Given a vector of variables (x), and a function (f) that estimates one function value, estimates the hessian matrix by numerical differencing. The hessian matrix is a square matrix of second-order partial derivatives of the function f with respect to x. It contains, on rows i and columns j

*d^2(f(x))/d(x_i)/d(x_j)*

1 |

`f ` |
function returning one function value, or a vector of function values. |

`x ` |
either one value or a vector containing the x-value(s) at which the hessian matrix should be estimated. |

`centered ` |
if TRUE, uses a centered difference approximation, else a forward difference approximation. |

`pert ` |
numerical perturbation factor; increase depending on precision of model solution. |

`... ` |
other arguments passed to function |

Function `hessian(f,x)`

returns a forward or centered difference
approximation of the gradient, which itself is also estimated by differencing.
Because of that, it is not very precise.

The gradient matrix where the number of rows equals the length of `f`

and the number of columns equals the length of `x`

.

the elements on i-th row and j-th column contain: *d((f(x))_i)/d(x_j)*

Karline Soetaert <karline.soetaert@nioz.nl>

`gradient`

, for a full (not necessarily square) gradient matrix

1 2 3 4 5 6 7 8 | ```
## =======================================================================
## the banana function
## =======================================================================
fun <- function(x) 100*(x[2] - x[1]^2)^2 + (1 - x[1])^2
mm <- nlm(fun, p = c(0, 0))$estimate
(Hes <- hessian(fun, mm))
# can also be estimated by nlm(fun, p=c(0,0), hessian=TRUE)
solve(Hes) # estimate of parameter uncertainty
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.