Finding the maximum likelihood estimates ?
Afficher commentaires plus anciens
I need to find the MLE estimates. My code is as below. It seems to give me the correct mean but incorrect variance.
function obj = kmlepdf(x,y)
f1 = -1*50*log(2*pi*(y(2)));
f2 = ((y(2)));
f3 = ((x-y(1)).^2);
obj = (f1 + sum(0.5*(f3./f2))); % Normal Function
end
clear all;
load data;
y0 = [0.5 0.5];
lb = [0 0];
ub = [10 10];
% Assign Data to a new variable
x = data;
% Calling the Least Square Minimization
opts=optimset('DerivativeCheck','on','Display','off','TolX',1e-6,'TolFun',1e- 6,'Diagnostics','off','MaxIter',200);
[y, fval] = fmincon(@(y)kmlepdf(x,y),y0,[],[],[],[],lb,ub,[],opts)
Réponses (1)
Tom Lane
le 24 Avr 2013
I believe you want
f1 = 0.5*length(x)*log(2*pi*(y(2)));
You start with 1/sqrt(2*pi*sigma^2), then take logs so you get a minus sign, but you need to negate again to get the negative log likelihood that you can minimize.
Also try setting lb(2)=eps.
Catégories
En savoir plus sur Statistics and Machine Learning Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!