mlecov
statistics: acov = mlecov (params, data, Name, Value)
Asymptotic covariance matrix of maximum likelihood estimators.
acov = mlecov (params, data, …)
returns an approximation to the asymptotic covariance matrix of the maximum
likelihood estimators of the parameters of a distribution, evaluated at the
parameter values in params for the sample data in data.
params is a numeric vector of parameter values (typically the estimates
returned by mle or fitdist) and data is a numeric vector
of the sample observations. acov is a matrix, where
.
The distribution is not identified by name; instead it is supplied through
Name-Value paired arguments that give function handles to its
density, its log density, or its negative log-likelihood. Exactly
one of the following three arguments must be specified:
| Name | Value |
|---|---|
'pdf' | A function handle,
f(data, p1, p2, …), that accepts the
sample data as its first argument and the distribution parameters as
subsequent scalar arguments, and returns a vector of probability density
values, one per observation. |
'logpdf' | A function handle,
f(data, p1, p2, …), with the same
calling convention as 'pdf' but returning the logarithm of
the density. |
'nloglf' | A function handle,
nll(params, data, cens, freq), that
returns the scalar negative log-likelihood of the whole sample. It receives
the current parameter vector, the data, the censoring vector, and the
frequency vector, and is responsible for incorporating censoring and
frequency itself. |
'cdf' | A function handle to the cumulative distribution
function, with the same calling convention as 'pdf'. It is
required together with 'pdf' when the data are censored, so
that censored observations can contribute their survival probability. |
'logsf' | A function handle to the logarithm of the survivor
function , with the same calling convention as
'pdf'. It is required together with 'logpdf' when
the data are censored. |
'Censoring' | A vector of the same size as data indicating censored observations (nonzero for right-censored). By default no observation is censored. |
'Frequency' | A vector of nonnegative integer counts of the
same size as data, giving the number of times each observation was
observed. By default it is ones (size (data)). |
'Options' | A structure that may contain a
'DerivStep' field specifying the relative finite-difference step
used to approximate the Hessian (a positive scalar or a vector the same size
as params). The default step is eps ^ (1/4). |
Source Code: mlecov
Computation and numerical behavior. mlecov approximates the
covariance matrix as the inverse of the observed Fisher information, that is,
the inverse of the Hessian of the aggregate negative log-likelihood of
the sample, evaluated by central finite differences at params. The
covariance is computed at the supplied params; mlecov
does not refit the parameters, so params should be the maximum
likelihood estimates for the result to be meaningful.
Whichever of 'pdf', 'logpdf', or 'nloglf' is
supplied, the Hessian is always formed by differencing the same aggregate
negative log-likelihood rather than by differentiating the density itself.
This makes the three input forms consistent with one another and is
numerically far more stable than differentiating a density; as a consequence
acov may differ from other implementations (including MATLAB) in
ill-conditioned cases where those differentiate the density directly and
return unreliable values or NaN. If the computed Hessian is not
positive definite (for example when params is not at a likelihood
maximum), a warning is issued and acov is returned as an
all-NaN matrix.
See also: mle, fitdist, makedist
Source Code: mlecov
Asymptotic covariance matrix of the ML estimates for a normal fit.
x = [2.1, 3.4, 1.9, 5.2, 4.1, 2.8, 3.3, 4.7, 2.2, 3.9, 3.0, 4.5]; phat = mle (x); acov = mlecov (phat, x, 'pdf', @(x, mu, sigma) normpdf (x, mu, sigma))
acov = 8.8767e-02 -6.6432e-11 -6.6432e-11 4.4384e-02