Description Usage Arguments Value Warnings Author(s) See Also Examples
View source: R/estfun.maxLik.R
Extract the gradients of the log-likelihood function evaluated
at each observation (‘Empirical Estimating Function’,
see estfun
).
1 2 | ## S3 method for class 'maxLik'
estfun( x, ... )
|
x |
an object of class |
... |
further arguments (currently ignored). |
Matrix of log-likelihood gradients at the estimated parameter value evaluated at each observation. Observations in rows, parameters in columns.
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.
Arne Henningsen
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.