numHessian | R Documentation |
Calculate a numerical approximation to the Hessian matrix of a function at a parameter value.
numHessian(func, theta, h = 0.0001, method=c("fast", "easy"), ...)
func |
a function for which the first (vector) argument is used as a parameter vector. |
theta |
the parameter vector first argument to func. |
h |
the step used in the numerical calculation. |
method |
one of "fast" or "easy" indicating the method to use for the approximation. |
... |
additional named or unmaned arguments to be passed to |
The function numHessian
calculates an numerical approximation to
the p by p second order derivative of a scalar real valued function with p-vector
argument theta.
This function can be used to check if the information matrix of a log likelihood is correct or not.
An p by p matrix of the Hessian of the function calculated at the
point theta
. If the func
is a log likelihood function,
then the negative of the p by p matrix is the information matrix.
numScore
g = function(x, a) (x[1]+2*x[2]^3 - x[3]^3 + a*sin(x[1]*x[2]))
x0= c(1, 2, 3)
numHessian(g, theta = x0, a = 9)
numHessian(g, theta = x0, method = 'easy', a = 9)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.