numScore: Calculate the Score / Jacobian Function

View source: R/bhm_lib.R

numScoreR Documentation

Calculate the Score / Jacobian Function

Description

Calculate a numerical approximation to the Score function of a function at a parameter value.

Usage

    numScore(func, theta, h = 0.0001, ...)
    numJacobian(func, theta, h = 0.0001, m = 2, ...)

Arguments

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.

m

the dimension of the function f(theta), default is 2.

...

additional named or unmaned arguments to be passed to func.

Details

The function numScore calculates an numerical approximation to the p by 1 first order derivative of a scalar real valued function with p-vector argument theta. This function can be used to check if the score function of a log likelihood is correct or not.

The function numJacobian calculates an numerical approximation to the m by p first order derivative of a m-vector real valued function with p-vector argument theta. This function can be used to find the solution of score functions for a log likelihood using the multiRoot function.

Value

An p by 1 vector of the score of the function calculated at the point theta. If the func is a log likelihood function, then the p by 1 vector is the score function.

See Also

numHessian multiRoot

Examples

  g = function(x, a) (x[1]+2*x[2]^3 - x[3]^3 + a*sin(x[1]*x[2]))
  x0 = c(1, 2, 3)
  numScore(g, x0, a = -3)

statapps/bhm documentation built on April 5, 2024, 3:31 a.m.