maxLik-methods.RdThese are methods for the maxLik related objects. See also the documentation for the corresponding generic functions
a ‘maxLik’ object (coef can also handle
‘maxim’ objects)
numeric, the penalty per parameter to be used; the default ‘k = 2’ is the classical AIC.
a ‘maxLik’ object
The standard errors are only calculated if the ratio of the smallest and largest eigenvalue of the Hessian matrix is less than “eigentol”. Otherwise the Hessian is treated as singular.
other arguments for methods
calculates Akaike's Information Criterion (and other information criteria).
extracts the estimated parameters (model's coefficients).
extracts standard errors (using the Hessian matrix).
## estimate mean and variance of normal random vector
set.seed(123)
x <- rnorm(50, 1, 2)
## log likelihood function.
## Note: 'param' is a vector
llf <- function( param ) {
mu <- param[ 1 ]
sigma <- param[ 2 ]
return(sum(dnorm(x, mean=mu, sd=sigma, log=TRUE)))
}
## Estimate it. Take standard normal as start values
ml <- maxLik(llf, start = c(mu=0, sigma=1) )
coef(ml)
#> mu sigma
#> 1.068807 1.833129
stdEr(ml)
#> mu sigma
#> 0.2592487 0.1833603
AIC(ml)
#> [1] 206.4963
#> attr(,"df")
#> [1] 2