%% Conduct a Wald Test Using Nonlinear Restriction Functions
% Test whether the parameters of a nested model have a nonlinear relationship.
% Load the Deutschmark/British Pound bilateral spot exchange rate data set.

load Data_MarkPound

% The data set (Data) contains a time series of prices.
%
% Convert the prices to returns, and plot the return series.

returns = price2ret(Data);

figure
plot(returns)
axis tight
ylabel('Returns')
xlabel('Days, 02Jan1984 - 31Dec1991')
title('{\bf Deutschmark/British Pound Bilateral Spot Exchange Rate}')

% The returns series shows signs of heteroscedasticity.
%
% Suppose that a GARCH(1,1) model is an appropriate model for the data. Fit a GARCH(1,1) model to the data including a constant.

Mdl = garch(1,1);
[EstMdl,EstParamCov] = estimate(Mdl,returns);
g1 = EstMdl.GARCH{1};
a1 = EstMdl.ARCH{1};

% g1 is the estimated GARCH effect, and a1 is the estimated ARCH effect.
%
% The following might represent relationships between the GARCH and ARCH coefficients:
% \gamma_1\alpha_1 = 1
% \gamma_1+\alpha_1 = 1
% where \gamma_1 is the GARCH effect and \alpha_1 is the ARCH effect. Specify these relationships as the restriction function r(\theta) = 0, evaluated at the unrestricted model parameter estimates. This specification defines a nested, restricted model.

r = [g1*a1; g1+a1] - 1;

%
% Specify the Jacobian of the restriction function vector.

R = [0, a1, g1;0, 1, 1];

%
% Conduct a Wald test to assess whether there is sufficient evidence to reject the restricted model.

[h,pValue,stat,cValue] = waldtest(r,R,EstParamCov)

% h = 1 indicates that there is sufficient evidence to reject the restricted model in favor of the unrestricted model.  pValue = 0 indicates that the evidence for rejecting the restricted model is strong.
% Copyright 2015 The MathWorks, Inc.