I want to use a distribution that is not built in to the rugarch package in R. More specifically, the EGB2 distribution. If I have the PDF of the distribution, is it then possible to use this distribution in my model like this for example?
# Defining the model specification
spec <- ugarchspec(
variance.model = list(
model = "eGARCH",
garchOrder = c(1, 1)
),
mean.model = list(
armaOrder = c(1, 1),
include.mean = TRUE
),
distribution.model = "eGB2"
)
Here, it will not recognize "eGB2" as a distribution model, but is there any way, that I can do that?
I have written the PDF of the distribution as a function in R, but I do not know how to use it with the rugarch package
This does not seem to be possible without hacking the {rugarch}
package itself. If you look in the package source you'll find this:
if(is.null(distribution.model)) modeldesc$distribution = "norm"
valid.distribution = c("norm", "snorm", "std", "sstd","ged", "sged", "nig", "ghyp", "jsu", "ghst")
distribution = distribution.model
if(!is.character(distribution[1]))
stop("\nugarchspec-->error: cond.distribution argument must be a character")
if(!any(distribution==valid.distribution))
stop("\nugarchspec-->error: the cond.distribution does not appear to be a valid choice.")
That checks whether the specified value for the distribution.model
is one of the valid options ("norm", "snorm", "std", "sstd","ged", "sged", "nig", "ghyp", "jsu" or "ghst") and if not then stops with an error.
You could fork a copy of the package from https://github.com/alexiosg/rugarch and adapt to support your new distribution. Very likely that the package maintainer will be pleased to receive a pull request with your proposed changes. Alternatively, you could ask the package maintainer to update the package to support your distribution.