numericDeriv              package:stats              R Documentation

Evaluate derivatives numerically

Description:

     'numericDeriv' numerically evaluates the gradient of an
     expression.

Usage:

     numericDeriv(expr, theta, rho=parent.frame())

Arguments:

    expr: The expression to be differentiated.  The value of this
          expression should be a numeric vector.

   theta: A character vector of names of variables used in 'expr'

     rho: An environment containing all the variables needed to
          evaluate 'expr'

Details:

     This is a front end to the C function 'numeric_deriv', which is
     described in _Writing R Extensions_.

Value:

     The value of 'eval(expr, env = rho)' plus a matrix attribute
     called 'gradient'.  The columns of this matrix are the derivatives
     of the value with respect to the variables listed in 'theta'.

Author(s):

     Saikat DebRoy saikat@stat.wisc.edu

Examples:

     myenv <- new.env()
     assign("mean", 0., env = myenv)
     assign("sd", 1., env = myenv)
     assign("x", seq(-3., 3., len = 31), env = myenv)
     numericDeriv(quote(pnorm(x, mean, sd)), c("mean", "sd"), myenv)

