%% Simulate Responses from ARIMAX Model
% Create models for the response and predictor series. Set an ARIMAX(2,1,3) model to the response MdlY, and an AR(1) model to the MdlX.

MdlY = arima('AR',{0.1 0.2},'D',1,'MA',{-0.1 0.1 0.05},...
'Constant',1,'Variance',0.5, 'Beta',2);
MdlX = arima('AR',0.5,'Constant',0,'Variance',0.1);

%
% Simulate a length 100 predictor series x and a series of iid normal disturbances z having mean zero and variance 1.

rng(1);
z = randn(100,1);
x = simulate(MdlX,100);

%
% Filter the disturbances z using MdlY to produce the response series y, and plot y.

y = filter(MdlY,z,'X',x);
figure;
plot(y);
title 'Filter to simulate ARIMA(2,1,3)';
xlabel 'Time';
ylabel 'Response';

% Copyright 2015 The MathWorks, Inc.