Asked by Diego Tintori
on 16 Nov 2019 at 21:40

k=garchFunction(u)

u=[0 0 0]

A=[0 1 1]

b=1

Aeq=[]

beq=[]

lb=[0 0 0]

up=[1 1 1]

[x,fval]=fminunc(@garchFunction,u,A,b,Aeq,beq,lb,up)

function y = garchFunction(x) %function for likelihood

Values1814=xlsread('C:\Users\pc\OneDrive - stud.unifi.it\Desktop\Econometrix\CAC40(2014-2018).csv','E2:E1024')

Values=Values1814/(10^6)

returns=tick2ret(Values)

returns=returns-mean(returns)

T=length(returns)

omega=x(1);

alpha=x(2);

beta=x(3);

sigma=zeros(T,1)

sigma(1)=0.011207749644594;

likelihood=0

for i=2:T;

sigma(i) = sqrt( omega + alpha*returns(i-1)^2 + beta*sigma(i-1)^2 );

likelihood = likelihood + 0.5*(-log(2*pi)-log(sigma(i)^2) - (returns(i)/sigma(i))^2);

end

y = -likelihood;

end

I have this function for the estimation of the maximum likelihood for garch. However, although it estimats perfectly the likelihood, once I want to minimize it trough the function fmincon i get the error shown in the Title. Can someone help me understand what is wrong? Thanks.

Opportunities for recent engineering grads.

Apply Today
## 12 Comments

## Matt J (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/491475-fmincon-getting-error-unable-to-perform-assignment-because-dot-indexing-is-not-supported-for-variabl#comment_768102

## Diego Tintori (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/491475-fmincon-getting-error-unable-to-perform-assignment-because-dot-indexing-is-not-supported-for-variabl#comment_768109

## Matt J (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/491475-fmincon-getting-error-unable-to-perform-assignment-because-dot-indexing-is-not-supported-for-variabl#comment_768266

## Walter Roberson (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/491475-fmincon-getting-error-unable-to-perform-assignment-because-dot-indexing-is-not-supported-for-variabl#comment_768269

## Diego Tintori (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/491475-fmincon-getting-error-unable-to-perform-assignment-because-dot-indexing-is-not-supported-for-variabl#comment_768270

## Walter Roberson (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/491475-fmincon-getting-error-unable-to-perform-assignment-because-dot-indexing-is-not-supported-for-variabl#comment_768273

## Diego Tintori (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/491475-fmincon-getting-error-unable-to-perform-assignment-because-dot-indexing-is-not-supported-for-variabl#comment_768275

## Walter Roberson (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/491475-fmincon-getting-error-unable-to-perform-assignment-because-dot-indexing-is-not-supported-for-variabl#comment_768276

## Diego Tintori (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/491475-fmincon-getting-error-unable-to-perform-assignment-because-dot-indexing-is-not-supported-for-variabl#comment_768278

## Walter Roberson (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/491475-fmincon-getting-error-unable-to-perform-assignment-because-dot-indexing-is-not-supported-for-variabl#comment_768282

## Diego Tintori (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/491475-fmincon-getting-error-unable-to-perform-assignment-because-dot-indexing-is-not-supported-for-variabl#comment_768287

## Walter Roberson (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/491475-fmincon-getting-error-unable-to-perform-assignment-because-dot-indexing-is-not-supported-for-variabl#comment_768338

Sign in to comment.