mle - Maximum likelihood estimates

Syntax

phat = mle(data)
[phat,pci] = mle(data)
[...] = mle(data,'distribution',dist)
[...] = mle(data,...,name1,val1,name2,val2,...)
[...] = mle(data,'pdf',pdf,'cdf',cdf,'start',start,...)
[...] = mle(data,'logpdf',logpdf,'logsf',logsf,'start',start,...)
[...] = mle(data,'nloglf',nloglf,'start',start,...)

Description

phat = mle(data) returns maximum likelihood estimates (MLEs) for the parameters of a normal distribution, computed using the sample data in the vector data.

[phat,pci] = mle(data) returns MLEs and 95% confidence intervals for the parameters.

[...] = mle(data,'distribution',dist) computes parameter estimates for the distribution specified by dist. Acceptable strings for dist are:

[...] = mle(data,...,name1,val1,name2,val2,...) specifies optional argument name/value pairs chosen from the following list.

NameValue

'censoring'

A Boolean vector of the same size as data, containing ones when the corresponding elements of data are right-censored observations and zeros when the corresponding elements are exact observations. The default is that all observations are observed exactly. Censoring is not supported for all distributions.

'frequency'

A vector of the same size as data, containing non-negative integer frequencies for the corresponding elements in data. The default is one observation per element of data.

'alpha'

A value between 0 and 1 specifying a confidence level of 100(1-alpha)% for pci. The default is 0.05 for 95% confidence.

'ntrials'

A scalar, or a vector of the same size as data, containing the total number of trials for the corresponding element of data. Applies only to the binomial distribution.

'options'

A structure created by a call to statset, containing numerical options for the fitting algorithm. Not applicable to all distributions.

mle can also fit custom distributions that you define using distribution functions, in one of three ways.

[...] = mle(data,'pdf',pdf,'cdf',cdf,'start',start,...) returns MLEs for the parameters of the distribution defined by the probability density and cumulative distribution functions pdf and cdf. pdf and cdf are function handles created using the @ sign. They accept as inputs a vector data and one or more individual distribution parameters, and return vectors of probability density values and cumulative probability values, respectively. If the 'censoring' name/value pair is not present, you can omit the 'cdf' name/value pair. mle computes the estimates by numerically maximizing the distribution's log-likelihood, and start is a vector containing initial values for the parameters.

[...] = mle(data,'logpdf',logpdf,'logsf',logsf,'start',start,...) returns MLEs for the parameters of the distribution defined by the log probability density and log survival functions logpdf and logsf. logpdf and logsf are function handles created using the @ sign. They accept as inputs a vector data and one or more individual distribution parameters, and return vectors of logged probability density values and logged survival function values, respectively. This form is sometimes more robust to the choice of starting point than using pdf and cdf functions. If the 'censoring' name/value pair is not present, you can omit the 'logsf' name/value pair. start is a vector containing initial values for the distribution's parameters.

[...] = mle(data,'nloglf',nloglf,'start',start,...) returns MLEs for the parameters of the distribution whose negative log-likelihood is given by nloglf. nloglf is a function handle, specified using the @ sign, that accepts the four input arguments:

nloglf must accept all four arguments even if you do not supply the 'censoring' or 'frequency' name/value pairs (see above). However, nloglf can safely ignore its cens and freq arguments in that case. nloglf returns a scalar negative log-likelihood value and, optionally, a negative log-likelihood gradient vector (see the 'GradObj' statset parameter below). start is a vector containing initial values for the distribution's parameters.

pdf, cdf, logpdf, logsf, or nloglf can also be cell arrays whose first element is a function handle as defined above, and whose remaining elements are additional arguments to the function. mle places these arguments at the end of the argument list in the function call.

The following optional argument name/value pairs are valid only when 'pdf' and 'cdf', 'logpdf' and 'logcdf', or 'nloglf' are given:

When fitting a custom distribution, use the 'options' parameter to control details of the maximum likelihood optimization. See statset('mlecustom') for parameter names and default values. mle interprets the following statset parameters for custom distribution fitting as follows:

ParameterValue
'GradObj'

'on' or 'off', indicating whether or not fmincon can expect the function provided with the 'nloglf' name/value pair to return the gradient vector of the negative log-likelihood as a second output. The default is 'off'. Ignored when using fminsearch.

'DerivStep'

The relative difference used in finite difference derivative approximations when using fmincon, and 'GradObj' is 'off'. 'DerivStep' can be a scalar, or the same size as 'start'. The default is eps^(1/3). Ignored when using fminsearch.

'FunValCheck'

'on' or 'off', indicating whether or not mle should check the values returned by the custom distribution functions for validity. The default is 'on'. A poor choice of starting point can sometimes cause these functions to return NaNs, infinite values, or out of range values if they are written without suitable error-checking.

'TolBnd'

An offset for upper and lower bounds when using fmincon. mle treats upper and lower bounds as strict inequalities (i.e., open bounds). With fmincon, this is approximated by creating closed bounds inset from the specified upper and lower bounds by TolBnd. The default is 1e-6.

Example

The following returns an MLE and a 95% confidence interval for the success probability of a binomial distribution with 20 trials:

data = binornd(20,0.75,100,1); % Simulated data, p = 0.75

[phat,pci] = mle(data,'distribution','binomial',...
                 'alpha',.05,'ntrials',20)
phat =
    0.7370
pci =
    0.7171
    0.7562

See Also

betafit, binofit, evfit, expfit, gamfit, gevfit, gpfit, lognfit, nbinfit, normfit, mlecov, poissfit, raylfit, statset, unifit, wblfit

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS