Hi!
I am trying to fit a GARCH model using the garch
function provided in the tseries
package.
Consider the following toy example (provided in the documentation):
n <- 1100
a <- c(0.1, 0.5, 0.2) # ARCH(2) coefficients
e <- rnorm(n)
x <- double(n)
x[1:2] <- rnorm(2, sd = sqrt(a[1]/(1.0-a[2]-a[3])))
for(i in 3:n) # Generate ARCH(2) process
{
x[i] <- e[i]*sqrt(a[1]+a[2]*x[i-1]^2+a[3]*x[i-2]^2)
}
x <- ts(x[101:1100])
x.arch <- garch(x, order = c(0,2)) # Fit ARCH(2)
summary(x.arch) # Diagnostic tests
plot(x.arch)
My problem is that while I define x.arch <- garch(x, order = c(0,2))
, it displays all the results, which I don't need. I just need to store the model and will extract the coefficients, residuals etc as per requirement. I can do it with x.arch
, but I don't really want to print the results to the console.
How can I suppress these unnecessary outputs? I tried with invisible
, but it didn't work.
Another problem is with the plot(x.arch)
line. It returns four graphs, and those are plotted one by one after the user hits the return key once for all of them.
Is there a way out to get these four plots simultaneouly? I tried par(ask = FALSE)
and devAskNewPage(ask = FALSE)
, but those attempts were in vain.
Thanks