Problem in estimating MLE with 'fimincon' function

Hello,
I recently started using Matlab and got stuck in a problem.
I am trying to verify that OLS estimators are same as those under the method of MLE under usual basic assumptions.
So I first made up a specification equation like below,
function [ fvale,gradf ] = lognormlike(w)
a= randn(1000,2); z = a(:,1); e = a(:,2); %date vector y = 2+3*z + e; <-----this is my equation I want to test. x = [ones(1000,1) z]; beta = [w(1);w(2)]; e2 = y - x*beta; [n,l] = size(x);
fvale = sum(log(normpdf(e2,0,w(3)))); gradf = [(w(3)^(-2))*x'*e2; (-1)*n/(2*w(3)^2) + ((2*w(3)^4)^(-1)) * e2'*e2];
end
I had no problem when I put some vector in my 'lognormlike'function. So I took the next step.
w0 = [4,1,2]; options = optimset('GradObj','on','LargeScale','on','Display','off'); [w,fval] = fmincon(@lognormlike,w0,[],[],[],[],[-100,-100,1],[100,100,100],[],options);
Here above is my simple maximization program using 'fimincon' function, and the problme popped up.
First, when I did run this program without 'GradObj', it said it needed gradient. So, I added. But When I added gradient and ran, it said like this,
'Warning: Your current settings will run a different algorithm (interior-point) in a future release. > In fmincon at 874 In norm_mle at 3 '
And every time I did run this program, it gave me different answer. I changed low bound and upper bound, but it did not fix the problem.(but value changed)
And When I did run this with 'Largescale off', it keeps giving me anwer whose value is same as initial value. I think I have some problme in choosing the algorithm for optimizaing, but I don't know where exactly I took a mistake.
One more, is there any method I can solve this problme with 'mle' built-in function? I mean when I have parametor in data, just like 'e2'.
It would be very helpful to me if you give an answer to my question since this is driving me crazy right now.........

Respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

lee
el 18 de Mzo. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by