Categories &

Functions List

Function Reference: mle

statistics: phat = mle (x)
statistics: phat = mle (x, Name, Value)
statistics: [phat, pci] = mle (…)

Compute maximum likelihood estimates.

phat = mle (x) returns the maximum likelihood estimates (MLEs) for the parameters of a normal distribution using the sample data in x, which must be a numeric vector of real values.

phat = mle (x, Name, Value) returns the MLEs with additional options specified by Name-Value pair arguments listed below.

NameValue
'distribution'A character vector specifying the distribution type for which to estimate parameters.
'Ntrials'A scalar specifying the number of trials for the corresponding element of x for the binomial distribution.
'theta'A scalar specifying the location parameter for the generalized Pareto distribution. It defaults to 0 and is not estimated: the data is shifted by it and only k and sigma are returned.
'mu'A scalar specifying the location parameter for the half-normal distribution.
'censoring'A vector of the same size as x indicating censored data in x. By default it is censor = zeros (size (x)).
'frequency'A vector of nonnegative integer counts of the same size as x used as frequency observations. By default it is freq = ones (size (x)).
'alpha'A scalar in the range (0,1), as the significance level for the confidence interval pci. By default it is 0.05 corresponding to 95% confidence intervals.
'options'A structure specifying the control parameters for the iterative algorithm used to compute ML estimates with the fminsearch function.
'pdf'A function handle @(data, p1, p2, …) to the probability density of a custom distribution, whose parameters are then estimated by maximum likelihood. Requires 'start'. It is mutually exclusive with 'distribution' and with 'logpdf'/'nloglf'.
'cdf'A function handle to the cumulative distribution function of the custom distribution, with the same calling convention as 'pdf'. Required together with 'pdf' for censored or truncated data.
'logpdf'A function handle to the log probability density of a custom distribution, with the same calling convention as 'pdf'. Requires 'start'.
'logsf'A function handle to the log survivor function log (1 - cdf) of the custom distribution, with the same calling convention as 'pdf'. Required together with 'logpdf' for censored data.
'nloglf'A function handle @(params, data, cens, freq) returning the scalar negative log-likelihood of a custom distribution. Requires 'start'.
'start'A vector of initial parameter values for a custom-distribution fit. Required with 'pdf', 'logpdf', or 'nloglf'.
'lowerbound'A scalar or vector of lower bounds for the custom-distribution parameters. By default they are unbounded below.
'upperbound'A scalar or vector of upper bounds for the custom-distribution parameters. By default they are unbounded above.
'truncationbounds'A two-element vector [L U] giving the truncation interval of a custom distribution. Requires a 'cdf' function.
'optimfun'The optimizer for a custom-distribution fit. Only 'fminsearch' is supported; bounded fits are handled by internal reparameterization of the constrained parameters.

Source Code: mle

When a custom distribution is specified through 'pdf', 'logpdf', or 'nloglf', the parameters are estimated by maximizing the likelihood with fminsearch, and the second output pci gives asymptotic normal (Wald) confidence intervals computed from the observed Fisher information at phat (see mlecov). Bounded parameters are estimated on an internally reparameterized unconstrained scale.

Distribution names are matched ignoring case, spaces and hyphens, so that 'Extreme Value', 'ExtremeValue' and 'extreme-value' all select the same distribution, and the same set of names is accepted by cdf, pdf, icdf, random, makedist, fitdist and mle.

This accepts more names than MATLAB. MATLAB takes the spaced and the squashed spelling but refuses the hyphenated one, so 'Birnbaum-Saunders' and 'Log-Logistic' are errors there; Octave has always accepted them and continues to. MATLAB also accepts 'tLocationScale' in makedist while refusing it in cdf for the same distribution; Octave accepts it, and 'location-scale T', everywhere. Code written against MATLAB’s names therefore runs unchanged, but code relying on these names will not port back.

See also: mlecov, fitdist, makedist

Source Code: mle

Fit a custom (normal) distribution by maximum likelihood and return the asymptotic 95% confidence intervals of the estimates.

 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];
 pdf = @(x, mu, sigma) normpdf (x, mu, sigma);
 [phat, pci] = mle (x, 'pdf', pdf, 'start', [mean(x), std(x)])
phat =

   3.4250   1.0321

pci =

   2.8411   0.6192
   4.0090   1.4450