%% Compare GARCH Model Specifications
% Assess whether a model containing two GARCH effects is more appropriate than a model with one GARCH effect for analyzing Deutschmark/British Pound foreign-exchange rates.
% Load the exchange rate data set.

load Data_MarkPound

%
% Convert the rates to returns.

returns = price2ret(Data);

%
% Fit the alternative, GARCH(2,1) model (UMdl) and the null, GARCH(1,1) model (RMdl) to the data.

UMdl = garch(2,1); % Unrestricted model
RMdl = garch(1,1); % Restricted model
[~,~,uLogL] = estimate(UMdl,returns,'Display','off');
[~,~,rLogL] = estimate(RMdl,returns,'Display','off');

% uLogL and rLogL are the maximized loglikelihood functions evaluated at the unrestricted and restricted model parameter estimates, respectively.
%
% Use the likelihood ratio test to compare the model specifications.

dof = 1; % One model restriction
[h,pValue,stat,cValue] = lratiotest(uLogL,rLogL,dof)

% h = 0 indicates that the test fails to reject the null, restricted GARCH(1,1) model in favor of the alternative, unrestricted GARCH(2,1) model.
% Copyright 2015 The MathWorks, Inc.