Finding the maximum likelihood estimates ?

2 ビュー (過去 30 日間)
Apurva Narayan
Apurva Narayan 2013 年 4 月 23 日
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 Center および File ExchangeSolver 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