As a part of my work I need the Maximum Likelihood Estimate that maximizes the log-likelihood of a vector. Can I use the in-built function 'mle' for this purpose?

In my work I have a vector of particular length 'L'. I want to maximize the log-likelihood estimate of the vector using maximum likelihood estimation. I have followed the following procedure:
x=[vector(1:L)];
[phat,pci]=mle(x);
des_signal=normpdf(x,phat(1),phat(2));
figure();
plot(des_signal)
However, I donot know whether the above command maximizes the log-likelihood. Also, the output I got was not the exact output that I needed but is somewhat similar. The distribution is assumed to be Normal distribution. Is there any other way to do the problem?

1 Comment

However, I donot know whether the above command maximizes the log-likelihood.
phat is such that it maximizes the log-likelihood.
Also, the output I got was not the exact output that I needed but is somewhat similar.
I already asked you to explain what you need.
Is there any other way to do the problem?
Why ? What is insufficient with what you get from "mle" ?

Sign in to comment.

Answers (1)

The ‘mle’ command does not return maximum log-likelihood estimates. Log of the likelihood is used for convenience as it simplifies the calculation for many of the derivations.
Please go through the following links for more information: -
log likelihood can be generated by taking log of the output after applying the ‘normpdf’ function.
Example,
>> des_signal = log(normpdf(x, phat(1), phat(2)));
The following functions can be used to get the sum of negative of log likelihood: -
Example,
>> pd = fitdist(x, >Normal>);
>> nll = negloglik(pd);
Regarding the second part of the question, in the code the function ‘normpdf’ evaluates the specified array of scalar values. For generating the normal curve, the input values must be sorted.
Example,
>> x = sort(x);
>> des_signal = normpdf(x, phat(1), phat(2));

4 Comments

Thank you @Shreyas, @Torsten my matrix have each row with one PQRST part of a ECG signal like that I have different rows equivalent to number of PQRST present in that particular ECG signal and I am taking each column as my observation vector (ad). I have to take log-likelihood estimation of these column vectors and using MLE, I have to maximize it. I have used negloglik(pd) for finding the negative log likelihood of the column vector. I am thinking of maximizing it using fminsearch(). But when I used negloglik(pd) I got scalar value. I don't know how to use it for maximization. Can you help me with this?
I have used negloglik(pd) for finding the negative log likelihood of the column vector. But when I used negloglik(pd) I got scalar value. I don't know how to use it for maximization. Can you help me with this?
The value you get from "negloglik" is already the maximum negative log likelihood value for the given data. No need to use fminsearch.
Maybe of interest how you can get this value on your own:
@Torsten Can I plot the distribution (desired PQRS complex) again using that value.
No. You have the parameters of the distribution (mu and sigma) using the "fitdist" command. Knowing these values, you can plot the distribution. The maximum likelihood value cannot be sufficient to fix the distribution.

Sign in to comment.

Asked:

on 25 Aug 2022

Commented:

on 6 Sep 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!