please help with the errror

1 visualizzazione (ultimi 30 giorni)
dav
dav il 27 Mag 2014
Commentato: James Kristoff il 27 Mag 2014
Hi I am trying to run the following program but it doesnt identify the function and gives me an error. can someone please help me with it?
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);
error:
Undefined function 'garch' for input arguments of type 'char'.
Error in test (line 32)
model1 = garch('Offset',NaN,'GARCHLags',1,'ARCHLags',1);
  1 Commento
Star Strider
Star Strider il 27 Mag 2014
The garch functions are in the Econometrics Toolbox.

Accedi per commentare.

Risposte (1)

James Kristoff
James Kristoff il 27 Mag 2014
As Star Strider stated, the command garch is part of the Econometrics Toolbox. If you want to find out if you have this toolbox installed, you can use the ver command.
You can also use the which command to find out if a command is on the MATLAB path e.g.
which -all plot
will list the locations of all plot functions on the MATLAB path.
  1 Commento
James Kristoff
James Kristoff il 27 Mag 2014
You can install the toolbox if it is on your license, or if you buy it. I am sure that you could do the math to "estimate the orders of p and q of a garch data set" without this function, but you would have to look up the related equations and implement them yourself in MATLAB. I do not know enough about this application to help implement the function by hand.

Accedi per commentare.

Categorie

Scopri di più su Conditional Variance Models in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by