I have a question: Objective function is undefined at initial point.

13 ビュー (過去 30 日間)
Imane Zemmouri
Imane Zemmouri 2021 年 12 月 7 日
コメント済み: Walter Roberson 2021 年 12 月 13 日
Hello,
I am trying to run a code and it always gave me the same error message:
Error using fminusub (line 16) Objective function is undefined at initial point. Fminunc cannot continue.
I really need some help with my initial starting values or objective function.
Any suggestions are welcomed!
Thanks.

採用された回答

Walter Roberson
Walter Roberson 2021 年 12 月 8 日
You have
function loglt = lnlt( b,yy)
and
a0=b(1:2);
a1=b(3:4);
b1=b(5:6);
c1=b(7:8);
pp=b(9:10);
where b is the parameters being passed in to be varied. The initial values that were passed in to fminunc for this purpose are in the variable start which is initialized to 3.1 * a where a=[a0 a1 b1 c1 pp]'; and a0=[1.0,1.5]; a1=[0.3,0.5];b1=[0.25,0.2]; c1=[0.65,0.5]; pp=[.2,.6]; .
Now, inside lnlt you have
for i = 2:nobs
hh(i)=a0(s(i))+a1(s(i))*indpositive(v(i-1))*log(v(i-1)^2)+b1(s(i))*indnegative(v(i-1))*log(v(i-1)^2);
h(i)=sqrt(exp((hh(i))))*h(i-1)^c1(s(i));
end
Observe the feedback, that the previous h^c1 is multiplied by a factor. If h becomes greater than 1 and c1 becomes greater than 1, then there is danger of an exponential explosion. With the initial values, c1 is indeed greater than 1, so the question becomes whether the multiplying factor is small enough to dampen the exponential growth. The answer to that is NO, that although some of the hh(i) are negative, so some of the sqrt(exp(hh)) are less than 1, the effect is not nearly enough to counter-act the exponential growth.
You need initial c1 values that involve at least one value less than 1 in order to have a hope in this, so that the sequence has some dampening.
However...
Your code is not suitable for use with fminunc() or fmincon() or any of the mathworks minimizers... including not being suitable for ga() .
All of the MATLAB minimizers rely upon the idea that if you process the same parameters twice, that you will get the same answer. But that is not true for your code: your code calls rando() to determine whether to use the first or second column of numbers, and rando() uses randn(), so your code is not deterministic and so cannot meaningfully be minimized.

その他の回答 (3 件)

Matt J
Matt J 2021 年 12 月 7 日
It looks like you didn't test your objective function to make sure that it runs error-free.
  3 件のコメント
Matt J
Matt J 2021 年 12 月 7 日
I mean you should run your objective function (separate from fminunc) with your initial point as input. If you get an error message or bad output, you'll know you haven't finished debugging your objective function code.
Imane Zemmouri
Imane Zemmouri 2021 年 12 月 8 日
I am sorry
Didn't succeed?

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


Imane Zemmouri
Imane Zemmouri 2021 年 12 月 8 日
Thank you a lot
=============================================
You need initial c1 values that involve at least one value less than 1 in order to have a hope in this, so that the sequence has some dampening.
=============================================
no hope of c1=[0.1,0.1]; or c1=[0.0,0.0]; or c1=[-0.2,0.3];
Thanks.
  3 件のコメント
Imane Zemmouri
Imane Zemmouri 2021 年 12 月 8 日
Thanks Dear.
Based on your wonderful and important feedback, I have modified file Ms_logGARCH_Lik.m
I ran the program but I got
_Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN. _ In MSlogGARCH_Simulation_Fit (line 99)
Sum log likelihood for Normal distribution - MS(2)-logGARCH(1,1)-->-Inf
What is the reason in your opinion?
Walter Roberson
Walter Roberson 2021 年 12 月 13 日
We would need your corrected source code to investigate further.

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


Imane Zemmouri
Imane Zemmouri 2021 年 12 月 8 日
Thanks Dear.
Based on your wonderful and important feedback, I have modified file Ms_logGARCH_Lik.m
I ran the program but I got
_Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN. _ In MSlogGARCH_Simulation_Fit (line 99)
Sum log likelihood for Normal distribution - MS(2)-logGARCH(1,1)-->-Inf
What is the reason in your opinion?
  1 件のコメント
John D'Errico
John D'Errico 2021 年 12 月 8 日
編集済み: John D'Errico 2021 年 12 月 8 日
Please stop writing a new answer every time you want to make a comment. Learn to use a comment instead.

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

カテゴリ

Help Center および File ExchangeConditional Variance Models についてさらに検索

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by