This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

lognlike

Lognormal negative loglikelihood

Syntax

nlogL = lognlike(params,x)
nlogL = lognlike(params,x,censoring)
nlogL = lognlike(params,x,censoring,freq)
[nlogL,aVar] = lognlike(___)

Description

example

nlogL = lognlike(params,x) returns the lognormal negative loglikelihood of the distribution parameters (params) given the sample data (x). params(1) and params(2) are the mean and standard deviation of logarithmic values, respectively.

nlogL = lognlike(params,x,censoring) specifies whether each value in x is right-censored or not. Use the logical vector censoring in which 1 indicates observations that are right-censored and 0 indicates observations that are fully observed.

nlogL = lognlike(params,x,censoring,freq) specifies the frequency or weights of observations. To specify freq without specifying censoring, you can pass [] for censoring.

example

[nlogL,aVar] = lognlike(___) also returns the inverse of the Fisher information matrix aVar, using any of the input argument combinations in the previous syntaxes. If values in params are the maximum likelihood estimates (MLEs) of the parameters, aVar is an approximation to the asymptotic covariance matrix.

Examples

collapse all

Find the MLEs of a data set with censoring by using mle, and then find the negative loglikelihood of the MLEs by using lognlike.

Generate 1000 random numbers from the lognormal distribution with the parameters 5 and 2.

rng('default') % For reproducibility
n = 1000; % Number of samples
x = lognrnd(5,2,[n,1]);

Find the MLEs for the distribution parameters (mean and standard deviation of logarithmic values) by using mle.

phat = mle(x,'distribution','LogNormal')
phat = 1×2

    4.9347    1.9969

Find the negative loglikelihood of the MLEs.

nlogL = lognlike(phat,x)
nlogL = 7.0453e+03

Find the maximum likelihood estimates (MLEs) of the lognormal distribution parameters, and then find the confidence interval of the corresponding cdf value.

Generate 1000 random numbers from the lognormal distribution with the parameters 5 and 2.

rng('default') % For reproducibility
n = 1000; % Number of samples
x = lognrnd(5,2,n,1);

Find the MLEs for the distribution parameters (mean and standard deviation of logarithmic values) by using mle.

phat = mle(x,'distribution','LogNormal')
phat = 1×2

    4.9347    1.9969

muHat = phat(1);
sigmaHat = phat(2);

Estimate the covariance of the distribution parameters by using lognlike. The function lognlike returns an approximation to the asymptotic covariance matrix if you pass the MLEs and the samples used to estimate the MLEs.

[~,pCov] = lognlike(phat,x)
pCov = 2×2

    0.0040   -0.0000
   -0.0000    0.0020

Find the cdf value at 0.5 and its 95% confidence interval.

[p,pLo,pUp] = logncdf(0.5,muHat,sigmaHat,pCov)
p = 0.0024
pLo = 0.0016
pUp = 0.0037

p is the cdf value of the lognormal distribution with the parameters muHat and sigmaHat. The interval [pLo,pUp] is the 95% confidence interval of the cdf evaluated at 0.5, considering the uncertainty of muHat and sigmaHat using pCov. The 95% confidence interval means the probability that [pLo,pUp] contains the true cdf value is 0.95.

Input Arguments

collapse all

Lognormal distribution parameters, specified as a vector of two numeric values. params(1) and params(2) are the mean and standard deviation of logarithmic values, respectively. params(2) must be positive.

Example: [0,1]

Data Types: single | double

Sample data, specified as a vector.

Data Types: single | double

Indicator for the censoring of each value in x, specified as a logical vector of the same size as x. Use 1 for observations that are right-censored and 0 for observations that are fully observed.

The default is an array of 0s, meaning that all observations are fully observed.

Data Types: logical

Frequency or weights of observations, specified as a nonnegative vector that is the same size as x. The freq input argument typically contains nonnegative integer counts for the corresponding elements in x, but can contain any nonnegative values.

To obtain the weighted negative loglikelihood for a data set with censoring, specify weights of observations, normalized to the number of observations in x.

The default is an array of 1s, meaning one observation per element of x.

Data Types: single | double

Output Arguments

collapse all

Negative loglikelihood value of the distribution parameters (params) given the sample data (x), returned as a numeric scalar.

Inverse of the Fisher information matrix, returned as a 2-by-2 numeric matrix. aVar is based on the observed Fisher information given the observed data (x), not the expected information.

If values in params are the MLEs of the parameters, aVar is an approximation to the asymptotic variance-covariance matrix (also known as the asymptotic covariance matrix). To find the MLEs, use mle.

Alternative Functionality

lognlike is a function specific to lognormal distribution. Statistics and Machine Learning Toolbox™ also offers the generic functions mlecov, fitdist, negloglik, and proflik and the Distribution Fitter app, which support various probability distributions.

  • mlecov returns the asymptotic covariance matrix of the MLEs of the parameters for a distribution specified by a custom probability density function. For example, mlecov(params,x,'pdf',@lognpdf) returns the asymptotic covariance matrix of the MLEs for the lognormal distribution.

  • Create a LognormalDistribution probability distribution object by fitting the distribution to data using the fitdist function or the Distribution Fitter app. The object property ParameterCovariance stores the covariance matrix of the parameter estimates. To obtain the negative loglikelihood of the parameter estimates and the profile of the likelihood function, pass the object to negloglik and proflik, respectively.

References

[1] Evans, M., N. Hastings, and B. Peacock. Statistical Distributions. 2nd ed. Hoboken, NJ: John Wiley & Sons, Inc., 1993.

[2] Lawless, J. F. Statistical Models and Methods for Lifetime Data. Hoboken, NJ: Wiley-Interscience, 1982.

[3] Meeker, W. Q., and L. A. Escobar. Statistical Methods for Reliability Data. Hoboken, NJ: John Wiley & Sons, Inc., 1998.

Extended Capabilities

Introduced before R2006a