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 tickerff = @(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
Best Answer