# gradient: Extract Gradients Evaluated at each Observation In maxLik: Maximum Likelihood Estimation and Related Tools

## Description

Extract the gradients of the log-likelihood function evaluated at each observation (‘Empirical Estimating Function’, see `estfun`).

## Usage

 ```1 2 3 4``` ```## S3 method for class 'maxLik' estfun(x, ...) ## S3 method for class 'maxim' gradient(x, ...) ```

## Arguments

 `x` an object inheriting from class `maxim` (for `gradient`) or `maxLik`. (for `estfun`.) `...` further arguments (currently ignored).

## Value

 `gradient` vector, objective function gradient at estimated maximum (or the last calculated value if the estimation did not converge.) `estfun` matrix, observation-wise log-likelihood gradients at the estimated parameter value evaluated at each observation. Observations in rows, parameters in columns.

## Warnings

The sandwich package must be loaded in order to use `estfun`.

`estfun` only works if the observaton-specific gradient information was available for the estimation. This is the case of the observation-specific gradient was supplied (see the `grad` argument for `maxLik`), or the log-likelihood function returns a vector of observation-specific values.

## Author(s)

Arne Henningsen, Ott Toomet

`hessian`, `estfun`, `maxLik`.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18``` ```## ML estimation of exponential duration model: t <- rexp(10, 2) loglik <- function(theta) log(theta) - theta*t ## Estimate with numeric gradient and hessian a <- maxLik(loglik, start=1 ) gradient(a) # Extract the gradients evaluated at each observation library( sandwich ) estfun( a ) ## Estimate with analytic gradient. ## Note: it returns a vector gradlik <- function(theta) 1/theta - t b <- maxLik(loglik, gradlik, start=1) gradient(a) estfun( b ) ```

maxLik documentation built on May 31, 2017, 2:13 a.m.