% simulatied a time series  of lenght 200 from the ARIMA(1,1,1) model
% (1-0.5B)(1-B)Y(t)=(1+0.3B)e(t) or
% Y(t)=1.5Y(t-1)-0.5Y(t-2)+e(t)+0.3e(t-1);

%initial value of Y_t,e_t

% initial Y(1) and Y(2);

Y(1:2)=0;


% initial random error value 
error(1)=randn(1,1);

% According to Model to produce data repeatedly
for i=3:205 
    error(i)=randn(1,1);
    Y(i)=1.5*Y(i-1)-0.5*Y(i-2)+error(i)+0.3*error(i-1);
end

% remove unstable initial values. 

Y=Y(6:205);

%plot figure 

% plot figure for ARIMA(1,1,1);
subplot(1,2,1);
plot(Y);

% add title for the figure.
title('From an ARIMA (1,1,1)');

% plot figure for difference of ARIMA(1,1,1);
subplot(1,2,2);
plot(Y(1:199)-Y(2:200));

% add title for the figure.
title('Difference of ARIMA (1,1,1)');