%% Test Time Series for Autocorrelation and ARCH Effects
% Load the Deutschmark/British pound foreign-exchange rate data set.

load Data_MarkPound

%
% Convert the prices to returns.

returns = price2ret(Data);

%
% Compute the deviations of the return series.

res = returns - mean(returns);

%
% Test the hypothesis that the residual series is not autocorrelated, using the default number of lags.

h1 = lbqtest(res)

% h1 = 0 indicates that there is not enough evidence to reject the null hypothesis that the residuals of the returns are not autocorrelated.
%
% Test the hypothesis that there are significant ARCH effects, using the default number of lags [3].

h2 = lbqtest(res.^2)

% h2 = 1 indicates that there are significant ARCH effects in the residuals of the returns.
%
% Test for residual heteroscedasticity using archtest and the default number of lags.

h3 = archtest(res)

% h3 = 1 indicates that the null hypothesis of no residual heteroscedasticity should be rejected in favor of an ARCH(1) model. This result is consistent with h2.
% Copyright 2015 The MathWorks, Inc.