Finding the maximum likelihood estimates ?

2 visualizaciones (últimos 30 días)
Apurva Narayan
Apurva Narayan el 23 de Abr. de 2013
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)

Respuestas (1)

Tom Lane
Tom Lane el 24 de Abr. de 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.

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by