Problem while using fmincon function with anonymous function: NOT ENOUGH INPUT ARGUMENTS

Hi there!
I am desperately trying to find the reason why fmincon won't work using the anonymous function created. (I am trying to maximize the log-likelihood function of two variances in the Kalman Filter or in other words to minimize minus-loglikelihood). The values of sigma_h and sigma_e have to be between 0 and 1. And I always get this error message, which is driving me crazy: "NOT ENOUGH INPUT ARGUMENTS". What am I doing wrong?
%%Maximize log-likelioood function
y = IVZ; % time series stock ticker
x = AMG; % time series stock ticker
ff = @(sigma_h,sigma_e) -loglikelihood(y,x,sigma_h,sigma_e);
x0 = [0.0001;0.0001];
A = [1,0;-1,0;0,1;0,-1];
b = [1;0;1;0];
estimation = fmincon(ff,x0,A,b)
Not enough input arguments.
Error in @(sigma_h,sigma_e)-loglikelihood(y,x,sigma_h,sigma_e)
Error in fmincon (line 535)
initVals.f = feval(funfcn{3},X,varargin{:});
Caused by:
Failure in initial objective function evaluation. FMINCON cannot continue.
By the way, my loglikelihood function looks as follows:
function [ loglikelihood ] = loglikelihood( y,x,sigma_h,sigma_e )
[S,e] = kalman2(y,x,sigma_h,sigma_e);
H = cumsum(log(S)+e.^2./S);
loglikelihood = -length(S)/2*log(2*pi)-0.5*H(end);
end

 採用された回答

Walter Roberson
Walter Roberson 2016 年 5 月 12 日
ff = @(sigma_he) -loglikelihood(y,x,sigma_he(1),sigma_he(2));

1 件のコメント

Thierry Tinguely
Thierry Tinguely 2016 年 5 月 12 日
Thank you so much Walter, it worked. This was extremely helpful!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeParallel Computing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by