numericDeriv

0th

Percentile

Evaluate Derivatives Numerically

numericDeriv numerically evaluates the gradient of an expression.

Keywords
models
Usage
numericDeriv(expr, theta, rho = parent.frame(), dir = 1.0)
Arguments
expr

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

theta

A character vector of names of numeric variables used in expr.

rho

An environment containing all the variables needed to evaluate expr.

dir

A numeric vector of directions to use for the finite differences.

Details

This is a front end to the C function numeric_deriv, which is described in Writing R Extensions.

The numeric variables must be of type real and not integer.

Value

The value of eval(expr, envir = 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.

Aliases
  • numericDeriv
Examples
library(stats) # NOT RUN { myenv <- new.env() assign("mean", 0., envir = myenv) assign("sd", 1., envir = myenv) assign("x", seq(-3., 3., len = 31), envir = myenv) numericDeriv(quote(pnorm(x, mean, sd)), c("mean", "sd"), myenv) # }
Documentation reproduced from package stats, version 3.5.0, License: Part of R 3.5.0

Community examples

Looks like there are no examples yet.