Mercurial > hg > octave-nkf
comparison scripts/signal/arch_test.m @ 3457:e031284eea27
[project @ 2000-01-19 08:49:56 by jwe]
author | jwe |
---|---|
date | Wed, 19 Jan 2000 08:50:14 +0000 |
parents | 858695b3ed62 |
children | d25bc039237b |
comparison
equal
deleted
inserted
replaced
3456:434790acb067 | 3457:e031284eea27 |
---|---|
58 ## minus the CDF of this distribution at LM) of the test. | 58 ## minus the CDF of this distribution at LM) of the test. |
59 ## | 59 ## |
60 ## If no output argument is given, the @var{p}-value is displayed. | 60 ## If no output argument is given, the @var{p}-value is displayed. |
61 ## @end deftypefn | 61 ## @end deftypefn |
62 | 62 |
63 ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> | 63 ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> |
64 ## Description: Test for conditional heteroscedascity | 64 ## Description: Test for conditional heteroscedascity |
65 | 65 |
66 function [pval, lm] = arch_test (y, X, p) | 66 function [pval, lm] = arch_test (y, X, p) |
67 | 67 |
68 if (nargin != 3) | 68 if (nargin != 3) |
69 error ("arch_test needs 3 input arguments"); | 69 error ("arch_test needs 3 input arguments"); |
70 endif | 70 endif |
71 | 71 |
72 if !(is_vector (y)) | 72 if (! (is_vector (y))) |
73 error ("arch_test: y must be a vector"); | 73 error ("arch_test: y must be a vector"); |
74 endif | 74 endif |
75 T = length (y); | 75 T = length (y); |
76 y = reshape (y, T, 1); | 76 y = reshape (y, T, 1); |
77 [rx, cx] = size (X); | 77 [rx, cx] = size (X); |
78 if ((rx == 1) && (cx == 1)) | 78 if ((rx == 1) && (cx == 1)) |
79 X = autoreg_matrix (y, X); | 79 X = autoreg_matrix (y, X); |
80 elseif !(rx == T) | 80 elseif (! (rx == T)) |
81 error (["arch_test: ", ... | 81 error ("arch_test: either rows(X) == length(y), or X is a scalar"); |
82 "either rows(X) == length(y), or X is a scalar"]); | |
83 endif | 82 endif |
84 if !(is_scalar(p) && (rem(p, 1) == 0) && (p > 0)) | 83 if (! (is_scalar(p) && (rem(p, 1) == 0) && (p > 0))) |
85 error ("arch_test: p must be a positive integer."); | 84 error ("arch_test: p must be a positive integer."); |
86 endif | 85 endif |
87 | 86 |
88 [b, v_b, e] = ols (y, X); | 87 [b, v_b, e] = ols (y, X); |
89 Z = autoreg_matrix (e.^2, p); | 88 Z = autoreg_matrix (e.^2, p); |
90 f = e.^2 / v_b - ones (T, 1); | 89 f = e.^2 / v_b - ones (T, 1); |