How to get the output to a variable

1 回表示 (過去 30 日間)
dav
dav 2014 年 6 月 2 日
コメント済み: Roger Wohlwend 2014 年 6 月 3 日
Hello,
I am using the following code to estimate garch parameters.
I get the estimates I want but I need to get the parameter estimates to three variables (constant, arch1, garch1) and NOT print the output generated by "GARCH" command.
Can someone please help me with this?
Thanks.
Code;
clc;
clear;
T = 300;
a0 = 0.1; a1 = 0.4; a2 = 0.0; b1 = 0.2; b2= 0.0; % garch parameters
epsi = randn(T+2000,1);
ut = zeros(T+2000,1); % garch data
sig2 = zeros(T+2000,1); % sigma squared in garch model
unvar = a0/(1-a1-a2-b1-b2); % unvar is the unconditional variance.. initial condition
for i = 1:T+2000
if i==1
sig2(i) = a0 + a1*unvar + a2*unvar + b1*unvar + b2*unvar;
sig =(sig2(i))^0.5;
ut(i) = epsi(i) * sig;
elseif i==2
sig2(i) = a0 + a1*(ut(1))^2 + a2*unvar + b1*sig2(1)+ b2*unvar;
sig =(sig2(i))^0.5;
ut(i) = epsi(i) * sig;
else
sig2(i) = a0 + a1*(ut(i-1))^2 + a2*(ut(i-2))^2 + b1*(sig2(i-1)) + b2*(sig2(i-2));
sig=(sig2(i))^0.5;
ut(i) = epsi(i) * sig;
end
end
utl = ut(2001:T+2000);
model1 = garch('Offset',NaN,'GARCHLags',1,'ARCHLags',1);
[fit1,~,LogL1] = estimate(model1,utl);
Output(I just need the parameter estimates):
GARCH(1,1) Conditional Variance Model:
----------------------------------------
Conditional Probability Distribution: Gaussian
Standard t
Parameter Value Error Statistic
----------- ----------- ------------ -----------
Constant 0.10871 0.0353215 3.07772
GARCH{1} 0.183931 0.160634 1.14503
ARCH{1} 0.375592 0.1073 3.50038
Offset 0.0219147 0.0238165 0.920149

採用された回答

George Papazafeiropoulos
George Papazafeiropoulos 2014 年 6 月 2 日
Try this after running your code:
fit1.Constant
fit1.GARCH{1}
fit1.ARCH{1}
fit1.Offset
  1 件のコメント
dav
dav 2014 年 6 月 2 日
thank you very much.
Is there a way stop stop printing the other parts of the output each time I run this code. I tried "display off" but it did not work.
thanks

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

その他の回答 (1 件)

Roger Wohlwend
Roger Wohlwend 2014 年 6 月 2 日
constant = fit1.Constant;
arch1 = fit1.ARCH{1};
garch1 = fit1.GARCH{1};
  2 件のコメント
dav
dav 2014 年 6 月 2 日
編集済み: dav 2014 年 6 月 2 日
thanks.
Is there a way to stop the whole output from being printing please? I just need to get the estimates.
thanks
Roger Wohlwend
Roger Wohlwend 2014 年 6 月 3 日
Yes, there is.
[fit1,~,LogL1] = estimate(model1,utl, 'Display', 'off');

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by