Help implementing GARCH model
5 views (last 30 days)
Show older comments
Im trying to use this package:
Specifically garchvar.m in that package.
The function is VaR = garchvar(data, model, distr, ar, ma, p, q, max_forecast, alpha) so I try something like
garchvar(lreturns, 'GARCH', 'GAUSSIAN', 1, 1, 1, 1, 5, 0.99) and I get the error message: "The constructor for class 'garch' must return only one output value".
Can anyone advise what Im doing wrong.
Thanks
0 Comments
Answers (1)
Cam Salzberger
on 31 Aug 2015
Hello Josh,
I understand that you are receiving an error when trying to call a function in a third party toolbox. The issue you are experiencing is the result of naming conflicts. The ARMAX-GARCH third party toolbox is trying to call a function garch, but there exists a class garch , with a constructor by the same name, in the built-in Econometrics Toolbox. Note that the garch object was introduced in the Econometrics Toolbox in R2012a, and the ARMAX-GARCH toolbox was last updated in 2011, so it is not the fault of the toolbox authors.
The MATLAB function precedence rules are such that class constructors in class folders would be called before functions in the current folder. The ideal fix to this is to change the ARMAX-GARCH garch function to a different name. However, you would also have to change every call to it from the toolbox to that name as well, which may be prohibitively time-consuming.
If you do not ever need to call the garch function explicitly outside of that toolbox, an alternative would be to put the garch function in a "private" folder within the toolbox. This works because functions in "private" folders have a higher precedence than class constructors. If you do this, the other toolbox functions can still access the toolbox's garch function, and calls to garch in code outside that toolbox will call the built-in class constructor.
I hope this helps resolve the issue.
-Cam
See Also
Categories
Find more on Conditional Variance Models in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!