Description Usage Arguments Value Warnings Author(s) See Also Examples
Extract the gradients of the log-likelihood function evaluated
at each observation (‘Empirical Estimating Function’,
see estfun
).
1 2 3 4 |
x |
an object inheriting from class |
... |
further arguments (currently ignored). |
|
vector, objective function gradient at estimated maximum (or the last calculated value if the estimation did not converge.) |
|
matrix, observation-wise log-likelihood gradients at the estimated parameter value evaluated at each observation. Observations in rows, parameters in columns. |
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.
Arne Henningsen, Ott Toomet
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 )
|
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] 3.053113e-09
[,1]
[1,] 0.3001989
[2,] -0.2607571
[3,] 0.3870227
[4,] 0.3950055
[5,] 0.4084085
[6,] 0.2221660
[7,] -0.4408378
[8,] -0.6214485
[9,] 0.3840342
[10,] -0.7737923
[1] 3.053113e-09
[,1]
[1,] 0.3001989
[2,] -0.2607571
[3,] 0.3870227
[4,] 0.3950055
[5,] 0.4084085
[6,] 0.2221660
[7,] -0.4408378
[8,] -0.6214485
[9,] 0.3840342
[10,] -0.7737923
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.