estfun.maxLik: Extract Gradients Evaluated at each Observation

Description Usage Arguments Value Warnings Author(s) See Also Examples

View source: R/estfun.maxLik.R

Description

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

Usage

1
2
## S3 method for class 'maxLik'
estfun( x, ... )

Arguments

x

an object of class maxLik.

...

further arguments (currently ignored).

Value

Matrix of 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 before this method can be used.

This method works only 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

See Also

estfun, maxLik.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## ML estimation of exponential duration model:
t <- rexp(100, 2)
loglik <- function(theta) log(theta) - theta*t

## Estimate with numeric gradient and hessian
a <- maxLik(loglik, start=1 )

# Extract the gradients evaluated at each observation
library( sandwich )
head(estfun( a ), 10)

## Estimate with analytic gradient.
## Note: it returns a vector
gradlik <- function(theta) 1/theta - t
b <- maxLik(loglik, gradlik, start=1)
head(estfun( b ), 10)

Example output

Loading required package: miscTools

Please cite the 'maxLik' package as:
Henningsen, Arne and Toomet, Ott (2011). maxLik: A package for maximum likelihood estimation in R. Computational Statistics 26(3), 443-458. DOI 10.1007/s00180-010-0217-1.

If you have questions, suggestions, or comments regarding the 'maxLik' package, please use a forum or 'tracker' at maxLik's R-Forge site:
https://r-forge.r-project.org/projects/maxlik/
             [,1]
 [1,]  0.27358194
 [2,]  0.43449741
 [3,]  0.09444664
 [4,]  0.39167460
 [5,]  0.14650982
 [6,] -0.61657145
 [7,]  0.10828263
 [8,]  0.06367943
 [9,]  0.24525371
[10,] -1.02765669
             [,1]
 [1,]  0.27358194
 [2,]  0.43449741
 [3,]  0.09444664
 [4,]  0.39167460
 [5,]  0.14650982
 [6,] -0.61657145
 [7,]  0.10828263
 [8,]  0.06367943
 [9,]  0.24525371
[10,] -1.02765669

maxLik documentation built on May 30, 2017, 1:07 a.m.

Search within the maxLik package
Search all R packages, documentation and source code