How to generate a GARCH series contaminated with outliers How can I simulate a GARCH series that is contaminated with both additive and innovative outliers?  My goal is compare different robust estimators. I am using R.  
 A: A simple example for GARCH(1,1) (the R code should be self-explanatory):
T=500
y=sigma.sq=rep(NA,T+1)
set.seed(1); innov=rnorm(T+1)
omega=0.05; alpha=0.1; beta=0.85
sigma.sq[1]=1/(alpha+beta)

# Below you specify the additive and multiplicative outliers
add.out=rep(0,T+1); add.out[100]=10; add.out[300]=20
mul.out=rep(1,T+1); mul.out[200]=10; add.out[400]=20

# Generate a GARCH(1,1) process with both additive and multiplicative outliers
for(t in 2:(T+1)){
 sigma.sq[t]=(omega+alpha*(sigma.sq[t-1]*innov[t-1]^2)+beta*sigma.sq[t-1]+add.out[t])*mul.out[t]
 y[t]=innov[t]*sqrt(sigma.sq[t])
}
sigma.sq=sigma.sq[-1]
y=y[-1]

# Plot the process and its conditional standard deviations
ylim=range( c( y,sqrt(sigma.sq) ) )
plot(y,type="l",ylim=ylim)
lines(sqrt(sigma.sq),col="red")


Here the outliers affect the conditional variance equation. You can easily change the code so that the outliers affect the realized values directly: replace
 sigma.sq[t]=(omega+(sigma.sq[t-1]*alpha*innov[t-1]^2)+beta*sigma.sq[t-1]+add.out[t])*mul.out[t]
 y[t]=innov[t]*sqrt(sigma.sq[t])

with
 sigma.sq[t]=omega+(sigma.sq[t-1]*alpha*innov[t-1]^2)+beta*sigma.sq[t-1]
 y[t]=(innov[t]*sqrt(sigma.sq[t])+add.out[t])*mul.out[t]


