how not to display everything

4 次查看(过去 30 天)
dav
dav 2014-6-3
编辑: dav 2014-6-3
Hi,
Every time I run the following code it displays lot of extra ouputs. I just need it to display the Aic values at the end.
Can someone please help me ?
much 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);
Mdl1 = garch('Offset',NaN,'GARCHLags',1,'ARCHLags',1);
[EstMdl1,EstParamCov1,logL(1)] = estimate(Mdl1,utl);
numParams(1) = sum(any(EstParamCov1));
Mdl2 = garch(5,5);
[EstMdl1,EstParamCov2,logL(2)] = estimate(Mdl2,utl);
numParams(2) = sum(any(EstParamCov2));
numObsv = length(utl);
[AIC1] = aicbic(logL(1), numParams(1))
[AIC2] = aicbic(logL(2), numParams(2))

回答(1 个)

Image Analyst
Image Analyst 2014-6-3
Here, study this function to see how I turn off warnings. The instructions for other warnings that you may encounter that are not turned off by my function are in the comments.
% Suppress warnings.
function TurnOffWarnings()
try
% To set the warning state, you must first know the message identifier for the one warning you want to enable.
% Query the last warning to acquire the identifier. For example:
% warnStruct = warning('query', 'last')
% messageID = warnStruct.identifier
% messageID =
% MATLAB:concatenation:integerInteraction
% Turn off this warning "Warning: Image is too big to fit on screen; displaying at 33% "
warning('off', 'Images:initSize:adjustingMag');
% Get rid of warning about roipolyold being deprecated:
% "Warning: Function ROIPOLYOLD will be removed in the future. Use ROIPOLY instead"
warning('off', 'images:removing:function');
% Get rid of warning about directory already existing:
% "Warning: Directory already exists."
warning('off', 'MATLAB:MKDIR:DirectoryExists');
% Turn off note "Warning: Added specified worksheet." that appears in the command window.
warning('off', 'MATLAB:xlswrite:AddSheet');
catch ME
errorMessage = sprintf('Error in function %s() at line %d.\nDo you have the file already open in Excel?\nPlease check that the file is not open anywhere.\n\nError Message:\n%s', ...
ME.stack(1).name, ME.stack(1).line, ME.message);
fprintf(1, '%s\n', errorMessage);
WarnUser(errorMessage);
end
return; % from TurnOffWarnings
  1 个评论
dav
dav 2014-6-3
Thanks I could prevent warnings from being displayed by using warning off command.
However, my biggest problem is preventing the following part from displaying.
Part that i want not to be displayed:
GARCH(1,1) Conditional Variance Model:
----------------------------------------
Conditional Probability Distribution: Gaussian
Standard t
Parameter Value Error Statistic
----------- ----------- ------------ -----------
Constant 0.102512 0.0240847 4.25631
GARCH{1} 0.134145 0.114463 1.17195
ARCH{1} 0.54348 0.124725 4.35742
Offset 0.0115701 0.0240859 0.480369
GARCH(0,3) Conditional Variance Model:
----------------------------------------
Conditional Probability Distribution: Gaussian
Standard t
Parameter Value Error Statistic
----------- ----------- ------------ -----------
Constant 0.121201 12.4444 0.00973944
ARCH{1} 0.547057 0.127185 4.30126
ARCH{2} 0.0434632 99.4938 0.000436843
ARCH{3} 0.020107 79.1013 0.000254193

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Conditional Variance Models 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by