Finding the maximum likelihood estimates ?

2 次查看(过去 30 天)
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)

回答(1 个)

Tom Lane
Tom Lane 2013-4-24
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.

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by