1. Currently I'm writing a complete new GARCH package, and as long as it is not
yet ready I have added the garch function from Adrian Trapletti's tseries package
to the fSeries package.
2. But the error in the output you observed comes not from the "garch" function,
it comes from my "garchSim" function. Please modify the function garchSim() in the
following way ----
garchSim =
function(model = list(omega = 1.0e-06, alpha = 0.1, beta = 0.8, mu = 0),
n = 100, innov = NULL, n.start = 100, start.innov = NULL, rand.gen = rnorm, ...)
{ # Doesn't work, replace the three following lines ... # if (!exists("model$alpha")) model$alpha = 0
# if (!exists("model$beta")) model$beta = 0
# if (!exists("model$mu")) model$mu = 0
# with ...
if (is.null(model$alpha)) model$alpha = 0
if (is.null(model$beta)) model$beta = 0
if (is.null(model$mu)) model$mu = 0
max.order = max(length(model$alpha), length(model$beta))
if (n.start < max.order)
stop("n.start must be greater or equal max(alpha, beta)")
if (is.null(start.innov))
start.innov = rand.gen(n.start, ...)
if (is.null(innov))
innov = rand.gen(n, ...)
h = x = z = c(start.innov, innov)
for (i in 1:max.order) {
h[i] = model$omega/(1 - sum(model$alpha) - sum(model$beta))
x[i] = sqrt(h[i]) * z[i] + model$mu
}
n.alpha = length(model$alpha)
n.beta = length(model$beta)
for (i in (max.order + 1):(n.start + n)) {
h[i] = model$omega + sum(model$alpha * x[i - (1:n.alpha)]^2) +
sum(model$beta * h[i - (1:n.beta)])
x[i] = sqrt(h[i]) * z[i] + model$mu
}
as.ts(x[-(1:n.start)])
}
and try the folloowing examples:
require(fSeries)
garchFit(garchSim(n = 1000))
garchFit(garchSim(model = list(omega = 1.0e-06, alpha = 0.1, beta = 0.8, mu = 0), n =1000))
garchFit(garchSim(model = list(omega = 1.0e-06, alpha = 0.6), n = 1000))
garchFit(garchSim(model = list(omega = 1.0e-06, alpha = 0.6), n = 1000),
order=c(0, 1))
The code will be updated in the next fSeries package. I apologize for any inconvenience caused by this bug.
Diethelm Wuertz
[EMAIL PROTECTED] wrote:
Good morning everyone,
I use for the first time the package fSeries and i try to run the example
given by Diethelm W�rtz. But when i run its example which is the following #
# Example: # Model a GARCH time series process #
# Description:
# PART I: Estimate GARCH models of the following type ARCH(2) # and GARCH(1,1) with normal conditional distribution functions.
# PART II: Simulate GARCH models of the following type, ARCH(2) # and GARCH(1,1),
# with normal conditional distribution functions.
#
# Author:
# (C) 2002, Diethelm Wuertz, GPL
#
############################################################################ #### # PART I: Estimation:
# Settings: set.seed(547) # Bollerslev's GARCH(1,1) with normal innovations: model = list(omega = 1e-6, alpha = 0.1, beta = 0.8, mu = 0) x = garchSim(model, n = 1000) fit = garchFit(as.numeric(x), order = c(1, 1)) print(fit) # Summary and Diagnostic Analysis: summary(fit) # Plot Results: par(mfrow = c(2, 2)) plot(fit) ###
Results of the estimations are false.
Call: garchFit(x = as.numeric(x), order = c(1, 1))
Coefficient(s):
omega a1 b1 8.564e-07 5.000e-02 5.000e-02
To compare with : omega = 1e-6, alpha = 0.1, beta = 0.8.
Do you have some information about this? Can I give some initials values to start the estimations? Can I use different innovation process like student-t and GED
Thanks for your answers
Cyril
[[alternative HTML version deleted]]
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
