How can I see specific likelihood values with MLE (or possibly another function?)

3 views (last 30 days)
Patrick Yee
Patrick Yee on 2 Nov 2021
Answered: Jeff Miller on 2 Nov 2021
I have some data and several experimental models with 3 free parameters. I would like to use aicbic to compare the models, and to do this, I need maximum likelihood estimates. I am trying to use the mle function, but it only seems to generate parameter estimates and not the actual likelihood values. Is there a fast way I can compute maximum likelihood values?
I am using a custom probability density function, by the way.
Other solutions not using mle are also appreciated! Thanks!

Answers (1)

Jeff Miller
Jeff Miller on 2 Nov 2021
Once you have the parameter estimates (e.g., from mle) you can compute the likelihood value by calling your custom density function for each data point with the estimated parameters and then getting the product of the results (log transformation often helpful). Something like this:
% function pdfval = mycustomdensity(x,parm1,parm2,parm3) % suppose this fn
% is in a file somewhere
% d is a vector of data points
pdf_d = zeros(numel(d),1);
for i=1:numel(d)
% parm1 etc these are the final estimates from mle
pdf_d(i) = mycustomdensity(d(i),parm1,parm2,parm3);
likelihood = prod(pdf_d);
lnlikelihood = sum(ln(pdf_d));
if your customdensity function can accept a vector of x and produce the corresponding vector of pdf values, you don't need the for loop.

Community Treasure Hunt

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

Start Hunting!

Translated by