%% Regression Model with ARIMA Errors and t Innovations
% This example shows how to set the innovation distribution of a regression model with ARIMA errors to a t distribution.
% Specify the regression model with ARIMA(3,1,2) errors:
% \begin{array}{c}{y_t} = {X_t}\left[ \begin{array}{l}2.5\\ - 0.6\end{array} \right] + {u_t}\\\left( {1 - 0.7L + 0.3{L^2} - 0.1{L^3}} \right)\left( {1 - L} \right){u_t} = \left( {1 + 0.5L + 0.2{L^2}} \right){\varepsilon _t},\end{array}
% where \varepsilon_t has a t distribution with the default degrees of freedom and unit variance.

Mdl = regARIMA('Intercept',0,'Beta',[2.5; -0.6],...
    'AR',{0.7, -0.3, 0.1},'MA',{0.5, 0.2},'Variance',1,...
    'Distribution','t','D',1)

% The default degrees of freedom is NaN. If you don't know the degrees of freedom, then you can estimate it by passing Mdl and the data to estimate.
%
% Specify a t_{10} distribution.

Mdl.Distribution = struct('Name','t','DoF',10)

% You can simulate or forecast responses by passing Mdl to simulate or forecast because Mdl is completely specified.
% In applications, such as simulation, the software normalizes the random t innovations. In other words, Variance overrides the theoretical variance of the t random variable (which is DoF/(DoF - 2)), but preserves the kurtosis of the distribution.
% Copyright 2015 The MathWorks, Inc.