Code covered by the BSD License  

Highlights from
Exercises in Advanced Risk and Portfolio Management

from Exercises in Advanced Risk and Portfolio Management by Attilio Meucci
text and comments on solutions available at http://symmys.com/node/170

S_VolatilityClustering.m
clc; close all; clear;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% input parameters

mu=.05;
a=.45;
b=.5;
s=.03;
T=10^3;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
z=randn(T,1);
s2=s^2;
for t=1:T-1
    s2(t+1)=s^2+a*s2(t)+b*(z(t)^2);
    eps(t+1)=mu+sqrt(s2(t+1))*z(t+1);
end

figure
plot(eps);
title('GARCH(1,1) process vs. time')

Contact us at files@mathworks.com