📄 bdssig.m
字号:
function sig = bdssig(w, n, m, eps)
%BDSSIG Significance level of the BDS statistic in small samples
%
% SIG = BDSSIG (W, N, M, EPS) evaluates the significance of BDS statistics W under the
% null hypothesis of iidness, using Kanzler's (1998) finite-sample quantile values.
%
% The significance levels can only assume 0.005, 0.010, 0.025, 0.050 or 1 (indicates
% failure to reject the null hypothesis) in value. These levels must be doubled to
% conduct what is normally a two-sided BDS test.
%
% N is the size of the sample on which the BDS statistics were computed.
%
% M can be either a scalar or a vector (corresponding to W) and represents
% the embedding dimension(s) for which the BDS statistics were computed.
% Only integers between 2 and 15 inclusive are permitted.
%
% EPS is the dimensional distance for which the BDS statistics were calculated.
% This is given in units of the standard deviation of approximately normally
% distributed samples, and only values 0.5, 1.0, 1.5 and 2.0 are allowed.
%
% See Kanzler (1998) on how estimation of the BDS statistic is to be correctly
% sized in normally as well as non-normally distributed samples. As the paper
% shows, EPS = 0.5 or 1.0 yield in many cases BDS distributions which are badly
% shaped, and while it is in principle possible to use this function to evaluate
% the significance of BDS statistics computed for either of these values, the
% results may not be very reliable, in particular if the number of observations
% is not close to one of the sample sizes for which the BDS distribution is
% tabulated in Kanzler (1998).
%
% Note also that estimation of any BDS statistics evaluated through this function
% must be based on an algorithm which makes use of the most efficient estimators
% of the various correlation integrals on which the BDS statistic is based. The
% author's own function BDS.M may be the only function for which this is true.
% See Kanzler (1998) on why this issue can be crucial to correctly sized estimation
% of the BDS statistic.
%
% Requires the MATLAB Statistics Toolbox.
%
% The author assumes no responsibility for errors or damage resulting from usage. All
% rights reserved. Usage of the programme in applications and alterations of the code
% should be referenced. This script may be redistributed if nothing has been added or
% removed and nothing is charged. Positive or negative feedback would be appreciated.
% Copyright (c) 15 Sept. 1998 by Ludwig Kanzler
% Department of Economics, University of Oxford
% Postal: Christ Church, Oxford OX1 1DP, U.K.
% E-mail: ludwig.kanzler@economics.oxford.ac.uk
% Homepage: http://users.ox.ac.uk/~econlrk
% $ Revision: 1.0 $ $ Date: 16 September 1998 $
%%%%%%%%%%%%%%%%%%%%%%%%%%% Check validity of input arguments %%%%%%%%%%%%%%%%%%%%%%%%%%%
mcases = 2 : 15;
epscases = [0.5 1.0 1.5 2.0];
ncases = [50 100 250 500 750 1000 2500];
siglevels = [0.005 0.010 0.025 0.050 1 0.050 0.025 0.010 0.005];
if nargin < 1
error('This function needs some argument input!')
elseif length(w) ~= length(w(:))
error('Cannot evaluate a matrix of BDS statistics; input must be a scalar or vector.')
elseif nargin < 2
n = inf;
end
if nargin < 3
m = 2 : length(w);
elseif unique([mcases, m(:)']) ~= 14
error('Cannot handle embedding dimension other than integers between 2 and 15.')
elseif length(m) ~= length(w) & length(m) ~= 1
error('Cannot handle a vector of embedding dimensions which is not as long as W.')
elseif length(m) == 1
m = m * ones(1, length(w));
end
if nargin < 4
eps = 1.5;
elseif ~sum(eps == epscases)
error('Cannot handle a dimensional distance other than 0.5, 1.0, 1.5 or 2.0.')
end
if n <= 5000
%%%%%%%%%%%%%%%%%%%%%%%%%% Setup of the quantile look-up table %%%%%%%%%%%%%%%%%%%%%%%%%%
% The quantile values are taken from Kanzler (1998) and are found along dimension 1
% (with the corresponding values for N(0,1) in parenthesis):
% < 0.5% (-2.58)
% < 1.0% (-2.33)
% < 2.5% (-1.96)
% < 5.0% (-1.65)
% > 95.0% ( 1.65)
% > 97.5% ( 1.96)
% > 99.0% ( 2.33)
% > 99.5% ( 2.58)
%
% Embedding dimensions m = [2 3 4 5 6 7 8 9 10 11 12 13 14 15] are along dimension 2.
%
% Sample sizes n = [50 100 250 500 750 1000 2500] are along dimension 3.
%
% Dimensional distances in units of the standard deviation of a normally distributed
% sample eps = [0.5 1.0 1.5 2.0] are along dimension 4.
quants = NaN * ones(8, 14, 7, 4);
% n = 50, eps = 0.5 (c1 ~ 0.27)
quants(1:8, 1:12, 1, 1) = [...
-22.66 -27.66 -31.41 -40.37 -54.26 -48.20 -40.93 -34.41 -28.99 -26.20 -22.25 -22.19
-13.87 -16.90 -19.92 -24.97 -28.85 -25.56 -21.97 -18.59 -16.45 -15.29 -14.53 -14.65
-8.01 -9.87 -12.09 -14.93 -15.79 -13.73 -11.88 -10.34 -9.30 -8.68 -8.71 -8.58
-5.75 -6.94 -8.74 -10.85 -10.85 -9.39 -7.98 -6.89 -6.33 -5.95 -5.81 -5.80
5.66 6.88 9.14 13.14 18.81 15.41 -0.68 -0.53 -0.40 -0.29 -0.21 -0.15
8.27 10.05 13.92 20.89 31.30 36.99 -0.44 -0.41 -0.30 -0.22 -0.15 -0.10
13.99 16.09 23.76 34.03 56.16 74.44 73.59 -0.29 -0.22 -0.15 -0.10 -0.07
21.47 27.66 37.27 57.80 89.30 118.37 147.67 45.58 -0.18 -0.12 -0.08 -0.05];
quants(1:8, 13:14, 1, 1) = [...
-22.79 -24.73
-14.99 -16.43
-8.98 -9.75
-5.89 -6.29
-0.11 -0.07
-0.07 -0.05
-0.04 -0.03
-0.03 -0.02];
% n = 50, eps = 1.0 (c1 ~ 0.51)
quants(1:8, 1:14, 1, 2) = [...
-4.66 -5.12 -5.55 -6.05 -6.45 -6.99 -7.46 -7.65 -7.89 -7.72 -8.09 -8.60 -9.37 -10.87
-4.10 -4.42 -4.67 -5.18 -5.49 -5.89 -6.27 -6.45 -6.57 -6.65 -6.69 -6.95 -7.70 -8.25
-3.35 -3.55 -3.78 -4.10 -4.37 -4.58 -4.92 -5.06 -5.13 -5.13 -5.06 -5.25 -5.45 -5.83
-2.84 -2.99 -3.12 -3.32 -3.54 -3.75 -4.01 -4.12 -4.20 -4.16 -4.03 -4.06 -4.17 -4.28
2.76 2.89 3.03 3.27 3.64 4.11 4.81 5.66 6.60 7.15 6.60 2.59 -0.18 -0.15
3.50 3.70 3.94 4.35 4.98 5.74 6.81 8.33 10.21 11.97 13.38 12.07 4.40 -0.10
4.52 4.90 5.25 5.97 6.78 8.21 9.89 12.32 15.44 20.26 24.66 27.84 26.77 16.38
5.43 5.82 6.46 7.24 8.60 10.65 12.56 16.11 21.04 26.66 34.22 40.93 46.54 46.35];
% n = 50, eps = 1.5 (c1 ~ 0.71)
quants(1:8, 1:14, 1, 3) = [...
-4.09 -4.01 -4.14 -4.08 -4.15 -4.30 -4.38 -4.53 -4.98 -5.32 -5.64 -6.19 -7.05 -7.52
-3.69 -3.65 -3.75 -3.69 -3.75 -3.92 -3.98 -4.12 -4.37 -4.64 -4.85 -5.19 -5.76 -6.35
-3.08 -3.12 -3.19 -3.19 -3.25 -3.32 -3.36 -3.49 -3.63 -3.74 -3.94 -4.21 -4.46 -4.74
-2.63 -2.67 -2.73 -2.75 -2.80 -2.84 -2.88 -2.97 -3.05 -3.14 -3.24 -3.40 -3.55 -3.74
2.46 2.46 2.47 2.46 2.44 2.47 2.53 2.60 2.67 2.76 2.85 2.95 3.07 3.20
3.01 3.04 3.07 3.07 3.14 3.27 3.34 3.48 3.64 3.78 3.96 4.25 4.54 4.87
3.64 3.69 3.76 3.91 4.05 4.26 4.43 4.62 4.92 5.22 5.65 6.13 6.54 7.09
4.15 4.11 4.26 4.57 4.70 4.96 5.22 5.56 6.05 6.40 6.90 7.41 8.29 9.19];
% n = 50, eps = 2.0 (c1 ~ 0.84)
quants(1:8, 1:14, 1, 4) = [...
-4.86 -4.77 -4.74 -4.67 -4.83 -4.89 -4.86 -5.14 -5.33 -5.48 -5.73 -6.05 -6.45 -6.89
-4.42 -4.34 -4.35 -4.28 -4.40 -4.48 -4.52 -4.62 -4.78 -4.88 -5.11 -5.32 -5.65 -5.94
-3.69 -3.68 -3.67 -3.69 -3.78 -3.79 -3.86 -3.96 -4.02 -4.09 -4.26 -4.41 -4.63 -4.87
-3.02 -3.09 -3.11 -3.15 -3.23 -3.25 -3.33 -3.38 -3.44 -3.53 -3.60 -3.69 -3.82 -3.98
2.83 2.80 2.79 2.76 2.72 2.72 2.71 2.71 2.67 2.68 2.65 2.62 2.61 2.62
3.50 3.42 3.46 3.44 3.44 3.42 3.40 3.40 3.41 3.39 3.44 3.46 3.48 3.52
4.23 4.26 4.19 4.22 4.27 4.22 4.25 4.24 4.30 4.40 4.48 4.53 4.55 4.74
4.70 4.77 4.71 4.72 4.81 4.82 4.91 4.93 5.08 5.16 5.21 5.30 5.44 5.53];
% n = 100, eps = 0.5 (c1 ~ 0.27)
quants(1:8, 1:14, 2, 1) = [...
-5.33 -6.39 -7.91 -9.88 -11.20 -9.92 -8.48 -7.07 -6.10 -5.59 -5.07 -4.83 -4.58 -4.41
-4.66 -5.51 -6.74 -8.49 -9.70 -8.72 -7.42 -6.29 -5.49 -4.88 -4.48 -4.14 -3.90 -3.83
-3.78 -4.50 -5.56 -6.90 -8.11 -7.44 -6.27 -5.35 -4.59 -4.04 -3.66 -3.39 -3.20 -3.03
-3.18 -3.71 -4.57 -5.67 -6.93 -6.44 -5.45 -4.62 -3.98 -3.50 -3.14 -2.86 -2.64 -2.50
3.24 3.83 4.77 6.61 9.80 14.90 20.07 -1.13 -0.96 -0.78 -0.63 -0.50 -0.41 -0.33
4.14 4.90 6.21 8.75 13.58 21.82 34.20 19.50 -0.82 -0.67 -0.53 -0.43 -0.34 -0.27
5.49 6.35 8.22 11.79 19.23 33.76 58.23 87.29 -0.61 -0.56 -0.45 -0.35 -0.28 -0.21
6.49 7.74 9.72 14.34 23.76 43.12 79.06 130.73 137.15 -0.47 -0.39 -0.30 -0.24 -0.18];
% n = 100, eps = 1.0 (c1 ~ 0.52)
quants(1:8, 1:14, 2, 2) = [...
-3.16 -3.23 -3.32 -3.42 -3.66 -3.90 -4.20 -4.41 -4.57 -4.57 -4.40 -4.27 -4.14 -4.03
-2.88 -2.93 -3.00 -3.12 -3.27 -3.50 -3.72 -3.97 -4.10 -4.12 -4.01 -3.85 -3.73 -3.63
-2.47 -2.52 -2.58 -2.66 -2.80 -2.93 -3.14 -3.34 -3.49 -3.52 -3.42 -3.30 -3.18 -3.06
-2.12 -2.16 -2.21 -2.29 -2.40 -2.53 -2.69 -2.87 -3.03 -3.07 -3.03 -2.90 -2.76 -2.64
2.16 2.20 2.28 2.41 2.60 2.80 3.13 3.61 4.18 5.01 6.01 7.12 7.81 7.05
2.64 2.73 2.85 3.05 3.28 3.67 4.16 4.84 5.68 6.96 8.84 10.88 12.77 14.23
3.25 3.37 3.56 3.87 4.18 4.77 5.42 6.40 7.74 9.92 12.57 16.04 21.06 26.29
3.72 3.81 4.06 4.39 4.94 5.58 6.37 7.58 9.39 12.14 15.70 20.87 27.11 35.25];
% n = 100, eps = 1.5 (c1 ~ 0.71)
quants(1:8, 1:14, 2, 3) = [...
-3.15 -3.12 -3.15 -3.14 -3.10 -3.14 -3.08 -3.13 -3.15 -3.23 -3.21 -3.27 -3.38 -3.49
-2.88 -2.88 -2.87 -2.87 -2.86 -2.86 -2.86 -2.85 -2.89 -2.95 -2.95 -2.99 -3.03 -3.15
-2.45 -2.48 -2.44 -2.47 -2.49 -2.49 -2.48 -2.48 -2.50 -2.50 -2.53 -2.56 -2.60 -2.63
-2.09 -2.11 -2.13 -2.12 -2.15 -2.16 -2.17 -2.16 -2.16 -2.17 -2.19 -2.22 -2.25 -2.28
2.02 2.02 2.00 2.03 2.02 2.05 2.06 2.13 2.18 2.24 2.31 2.39 2.50 2.62
2.47 2.48 2.45 2.49 2.54 2.59 2.65 2.72 2.82 2.94 3.09 3.25 3.41 3.60
2.98 3.01 3.03 3.07 3.16 3.23 3.31 3.48 3.64 3.87 4.10 4.35 4.64 5.02
3.27 3.41 3.45 3.50 3.61 3.72 3.86 4.05 4.26 4.46 4.84 5.16 5.56 6.10];
% n = 100, eps = 2.0 (c1 ~0.84)
quants(1:8, 1:14, 2, 4) = [...
-3.66 -3.60 -3.56 -3.52 -3.43 -3.44 -3.43 -3.47 -3.46 -3.48 -3.48 -3.56 -3.56 -3.62
-3.28 -3.24 -3.25 -3.25 -3.17 -3.14 -3.15 -3.16 -3.18 -3.20 -3.16 -3.24 -3.26 -3.31
-2.73 -2.75 -2.77 -2.81 -2.76 -2.73 -2.74 -2.72 -2.74 -2.76 -2.76 -2.80 -2.81 -2.82
-2.28 -2.33 -2.37 -2.38 -2.37 -2.36 -2.37 -2.37 -2.38 -2.37 -2.39 -2.41 -2.43 -2.44
2.26 2.22 2.17 2.17 2.17 2.15 2.14 2.14 2.14 2.13 2.13 2.13 2.14 2.14
2.77 2.71 2.69 2.67 2.66 2.67 2.67 2.72 2.71 2.72 2.75 2.77 2.77 2.78
3.34 3.35 3.32 3.32 3.32 3.34 3.37 3.39 3.40 3.44 3.48 3.56 3.59 3.60
3.73 3.74 3.76 3.78 3.74 3.78 3.84 3.92 3.93 4.00 4.04 4.07 4.10 4.23];
% n = 250, eps = 0.5 (c1 ~ 0.27)
quants(1:8, 1:14, 3, 1) = [...
-3.25 -3.64 -4.32 -5.44 -6.76 -8.03 -7.35 -6.27 -5.29 -4.57 -4.01 -3.58 -3.22 -2.90
-2.94 -3.32 -3.91 -4.85 -6.19 -7.40 -6.95 -5.91 -5.02 -4.33 -3.77 -3.35 -3.02 -2.72
-2.54 -2.86 -3.29 -4.11 -5.19 -6.55 -6.30 -5.40 -4.59 -3.95 -3.46 -3.05 -2.71 -2.45
-2.18 -2.40 -2.79 -3.47 -4.45 -5.78 -5.83 -5.00 -4.25 -3.65 -3.17 -2.80 -2.48 -2.23
2.27 2.50 2.98 3.79 5.19 7.68 12.18 18.51 13.10 -1.69 -1.44 -1.23 -1.05 -0.90
2.81 3.13 3.75 4.78 6.63 10.09 16.49 28.55 43.94 -1.52 -1.34 -1.13 -0.96 -0.82
3.49 3.90 4.70 6.00 8.37 13.11 22.93 42.19 73.31 98.79 -1.20 -1.03 -0.87 -0.74
3.96 4.49 5.42 7.01 9.81 15.49 28.61 54.34 102.44 165.50 -1.08 -0.94 -0.82 -0.69];
% n = 250, eps = 1.0 (c1 ~ 0.52)
quants(1:8, 1:14, 3, 2) = [...
-2.63 -2.57 -2.58 -2.61 -2.67 -2.70 -2.81 -2.96 -3.12 -3.32 -3.51 -3.53 -3.44 -3.24
-2.42 -2.38 -2.39 -2.40 -2.44 -2.48 -2.59 -2.72 -2.87 -3.06 -3.28 -3.33 -3.24 -3.08
-2.09 -2.11 -2.09 -2.10 -2.13 -2.18 -2.24 -2.37 -2.51 -2.71 -2.91 -3.01 -2.99 -2.83
-1.81 -1.83 -1.83 -1.84 -1.86 -1.90 -1.97 -2.06 -2.20 -2.37 -2.57 -2.73 -2.76 -2.63
1.83 1.88 1.88 1.95 2.03 2.15 2.25 2.45 2.71 3.05 3.56 4.21 5.05 6.33
2.26 2.30 2.35 2.44 2.54 2.69 2.88 3.12 3.49 3.93 4.68 5.60 6.99 8.82
2.76 2.82 2.93 3.01 3.18 3.40 3.78 4.11 4.58 5.21 6.22 7.76 9.79 12.75
3.08 3.15 3.31 3.47 3.70 3.97 4.39 4.91 5.38 6.49 7.70 9.43 12.14 15.87];
% n = 250, eps = 1.5 (c1 ~ 0.71)
quants(1:8, 1:14, 3, 3) = [...
-2.72 -2.70 -2.67 -2.63 -2.60 -2.55 -2.51 -2.49 -2.49 -2.45 -2.46 -2.44 -2.43 -2.43
-2.48 -2.49 -2.46 -2.43 -2.40 -2.37 -2.32 -2.31 -2.29 -2.29 -2.27 -2.26 -2.25 -2.25
-2.13 -2.12 -2.14 -2.13 -2.10 -2.08 -2.04 -2.02 -2.03 -2.01 -2.00 -1.98 -1.99 -1.99
-1.81 -1.81 -1.85 -1.84 -1.82 -1.81 -1.79 -1.77 -1.77 -1.75 -1.76 -1.75 -1.75 -1.74
1.82 1.82 1.82 1.84 1.85 1.87 1.89 1.92 1.94 1.98 2.02 2.06 2.11 2.16
2.22 2.22 2.25 2.25 2.29 2.33 2.35 2.40 2.44 2.52 2.55 2.63 2.73 2.82
2.68 2.67 2.74 2.77 2.84 2.90 2.94 3.02 3.09 3.15 3.28 3.46 3.59 3.73
2.97 3.01 3.09 3.12 3.19 3.27 3.28 3.41 3.52 3.66 3.85 3.97 4.20 4.42];
% n = 250, eps = 2.0 (c1 ~ 0.84)
quants(1:8, 1:14, 3, 4) = [...
-2.90 -2.88 -2.87 -2.86 -2.89 -2.83 -2.77 -2.74 -2.76 -2.73 -2.68 -2.68 -2.66 -2.62
-2.62 -2.64 -2.63 -2.61 -2.59 -2.59 -2.56 -2.51 -2.52 -2.50 -2.49 -2.48 -2.45 -2.43
-2.25 -2.26 -2.24 -2.24 -2.24 -2.23 -2.22 -2.22 -2.19 -2.18 -2.18 -2.17 -2.15 -2.13
-1.91 -1.92 -1.93 -1.93 -1.93 -1.94 -1.93 -1.93 -1.91 -1.91 -1.89 -1.89 -1.89 -1.88
1.88 1.86 1.86 1.86 1.85 1.83 1.83 1.84 1.85 1.85 1.85 1.87 1.88 1.88
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -