from Exact Negative Log-likelihood of ARMA models via Kalman Filtering by Statovic
Computation of the exact negative log-likelihood of ARMA models using the Kalman Filter

arma_ConvertToSS(A, C, v)
% [F, R, H, Q] = arma_ConvertToSS(A, C, v)
% Convert an ARMA input-output model into a state space representation
%
% Parameters:
%   A     = autoregressive coefficients (sans leading '1')
%   C     = moving average coefficients (sans leading '1')
%   v     = innovation variance
%
% Returns:
%   F     = state transition matrix 
%   R     = innovation gain vector
%   H     = measurement equation vector
%   Q     = innovation noise matrix
%
% References:
%
%   (1) Algorithm AS154: An Algorithm for Exact Maximum Likelihood Estimation of Autoregressive-Moving Average Models by Means of Kalman Filtering
%       G.Gardner, A.C.Harvey and G.D.A.Phillips
%       Applied Statistics, Vol. 29, No. 3, 1980, pp. 311-322
% 
% (c) Copyright Daniel F. Schmidt 2008
%
function [F, R, H, Q] = arma_ConvertToSS(A, C, v)

% Build the matrices
C = [1, C];
m = max(length(A), length(C));

A = [A zeros(1, m-length(A))];
C = [C zeros(1, m-length(C))];

% SS matrices
F = [-A' [eye(m-1, m-1); zeros(1, m-1)] ];
R = C';
H = [1 zeros(1, m-1)];
Q = R*R' * v;

Contact us at files@mathworks.com