Skip to content

Garch, beginner questions

2 messages · Benjamin Dickgiesser

#
Hi all,

if I use
fit = garchFit(~arma(2,0), ~garch(1,1), series = rt)

does fit at fitted.values hold the fitted standard deviations? The manual
only says
@fitted.values 	a numeric vector with the fitted values.
I'm not sure if this means the fitted values from the arma or the variance..

Is there also a function to estimate a AR-Garch model with t
distributed innovations? I'm trying to calculate the Value at Risk
using the models outlined above.

I really appreciate your help,
Benjamin
#
I now wrote this function, but am sure it can be done much better somehow..

library(fSeries)
library(tseries)

VaR.Garch <- function(data,stockId=1,p=0.01,dt=1)
{
	r <- diff(log(data))
	
	#fit Garch(1,1), Ar(2) modell
	fit = garchFit(~arma(2,0), ~garch(1,1), series = r)
	
	#init vars
	rhat[1:3] <- 0
	a[1:3] <- 0
	sigma[1:3] <- 0
	VaR[1:3] <- 0
	
	for (t in 3:length(r))
	{	
		#Calculate r suggested by AR	
		rhat[t] <- fit at fit$matcoef[1,1] + fit at fit$matcoef[2,1] * r[t-1] +
fit at fit$matcoef[3,1]*  r[t-2]
		#calculate error from fitted AR
		a[t] 		<- r[t] - rhat[t]
		#estimate sigma
		sigma[t] 	<- sqrt(fit at fit$matcoef[4,1] + fit at fit$matcoef[5,1] *
sigma[t-1]^2 + fit at fit$matcoef[6,1] * a[t - 1]^2)
		# calculate the value at risk
		VaR[t] <- (1 - exp(rhat[t] * dt + sqrt(dt) * qnorm(p) * sigma[t])) * data[t]
	}
	list(VaR=VaR,r=rhat,std=sigma)
}
On 11/21/06, Benjamin Dickgiesser <dickgiesser at gmail.com> wrote: