주요 콘텐츠

explike

Exponential negative loglikelihood

Description

nlogL = explike(mu,x) returns the exponential negative loglikelihood of the parameter mu, given the sample data x.

example

nlogL = explike(mu,x,censoring) specifies whether each value in x is right-censored or not. Use the logical vector censoring to specify the value 1 for observations that are right-censored and 0 for observations that are fully observed.

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

[nlogL,aVar] = explike(___) also returns the inverse of the Fisher information aVar, a scalar, using any of the input argument combinations in the previous syntaxes. If the input parameter value in mu is the maximum likelihood estimate (MLE), aVar is its asymptotic variance. aVar is based on the observed Fisher information, not the expected information.

example

Examples

collapse all

Find the maximum likelihood estimate (MLE) of a random data set drawn from the exponential distribution by using the mle function, and then find the negative loglikelihood of the MLE by using the explike function.

Generate 1000 random numbers from the exponential distribution with the mean parameter mu=2.

rng(0,"twister") % For reproducibility
n = 1000; % Number of samples
mu = 2;
x = exprnd(mu,[n,1]);

Find the MLE for the mean parameter.

pHat = mle(x,Distribution="Exponential")
pHat = 
2.0051

Compute the negative loglikelihood of the MLE and the inverse of the Fisher information.

[nlogL,aVar] = explike(pHat,x)
nlogL = 
1.6957e+03
aVar = 
0.0040

Because pHat is an MLE value, aVar is the asymptotic variance of pHat.

Input Arguments

collapse all

Exponential mean parameter, specified as a positive scalar value.

Data Types: single | double

Sample data, specified as a numeric 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 the 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 exponential distribution mean parameter given the sample data (x), returned as a numeric scalar.

Inverse of the Fisher information, returned as a numeric scalar. aVar is based on the observed Fisher information given the observed data (x), not the expected information. If mu is the MLE, then aVar is its asymptotic variance.

Alternative Functionality

explike is a function specific to the exponential 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",@exppdf) returns the asymptotic covariance matrix of the MLEs for the exponential distribution.

  • Create an ExponentialDistribution 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.

Extended Capabilities

expand all

Version History

Introduced before R2006a