%% Estimate Parameters of Regression Model Containing ARIMA Errors Without Initial Values
% Fit this regression model with ARMA(2,1) errors to simulated data:
% \begin{array}{*{20}{l}}
% \begin{array}{c}
% {y_t} = {X_t}\left[ {\begin{array}{*{20}{c}}
% {0.1}\\
% { - 0.2}
% \end{array}} \right] + {u_t}\\
% {u_t} = 0.5{u_{t - 1}} - 0.8{u_{t - 2}} + {\varepsilon _t} - 0.5{\varepsilon _{t - 1}},
% \end{array}
% \end{array}
% where \varepsilon_{t} is Gaussian with variance 0.1.
% Specify the regression model ARMA(2,1) errors. Simulate responses from the model and two predictor series.

Mdl0 = regARIMA('Intercept',0,'AR',{0.5 -0.8}, ...
    'MA',-0.5,'Beta',[0.1 -0.2],'Variance',0.1);
rng(1);
X =  randn(100,2);
y = simulate(Mdl0,100,'X',X);

%
% Specify a regression model with ARMA(2,1) errors with no intercept, and unknown coefficients and variance.

Mdl = regARIMA(2,0,1);
Mdl.Intercept = 0      % Exclude the intercept

% The AR coefficients, MA coefficients, and the innovation variance are NaN values. estimate estimates those parameters, but not the intercept. The intercept is held fixed at 0.
%
% Fit the regression model with ARMA(2,1) errors to the data.

EstMdl = estimate(Mdl,y,'X',X,'Display','params');

% The result, EstMdl, is a new regARIMA model. The estimates in EstMdl resemble the parameter values that generated the simulated data.
% Copyright 2015 The MathWorks, Inc.