1 # Created by Octave 3.6.1, Thu Apr 05 12:32:56 2012 UTC <root@brouzouf>
13 # name: <cell-element>
17 Calculates adaptive autoregressive (AAR) and adaptive autoregressive moving average estimates (AARMA)
18 of real-valued data series using Kalman filter algorithm.
19 [a,e,REV] = aar(y, mode, MOP, UC, a0, A, W, V);
21 The AAR process is described as following
22 y(k) - a(k,1)*y(t-1) -...- a(k,p)*y(t-p) = e(k);
23 The AARMA process is described as following
24 y(k) - a(k,1)*y(t-1) -...- a(k,p)*y(t-p) = e(k) + b(k,1)*e(t-1) + ... + b(k,q)*e(t-q);
28 Mode is a two-element vector [aMode, vMode],
29 aMode determines 1 (out of 12) methods for updating the co-variance matrix (see also [1])
30 vMode determines 1 (out of 7) methods for estimating the innovation variance (see also [1])
31 aMode=1, vmode=2 is the RLS algorithm as used in [2]
32 aMode=-1, LMS algorithm (signal normalized)
33 aMode=-2, LMS algorithm with adaptive normalization
35 MOP model order, default [10,0]
36 MOP=[p] AAR(p) model. p AR parameters
37 MOP=[p,q] AARMA(p,q) model, p AR parameters and q MA coefficients
38 UC Update Coefficient, default 0
39 a0 Initial AAR parameters [a(0,1), a(0,2), ..., a(0,p),b(0,1),b(0,2), ..., b(0,q)]
40 (row vector with p+q elements, default zeros(1,p) )
41 A Initial Covariance matrix (positive definite pxp-matrix, default eye(p))
42 W system noise (required for aMode==0)
43 V observation noise (required for vMode==0)
46 a AAR(MA) estimates [a(k,1), a(k,2), ..., a(k,p),b(k,1),b(k,2), ..., b(k,q]
47 e error process (Adaptively filtered process)
48 REV relative error variance MSE/MSY
52 The mean square (prediction) error of different variants is useful for determining the free parameters (Mode, MOP, UC)
55 [1] A. Schloegl (2000), The electroencephalogram and the adaptive autoregressive model: theory and applications.
56 ISBN 3-8265-7640-3 Shaker Verlag, Aachen, Germany.
58 More references can be found at
59 http://www.dpmi.tu-graz.ac.at/~schloegl/publications/
63 # name: <cell-element>
67 Calculates adaptive autoregressive (AAR) and adaptive autoregressive moving ave
71 # name: <cell-element>
78 # name: <cell-element>
82 Estimating Adaptive AutoRegressive-Moving-Average-and-mean model (includes mean term)
84 !! This function is obsolete and is replaced by AMARMA
86 [z,E,REV,ESU,V,Z,SPUR] = aarmam(y, mode, MOP, UC, z0, Z0, V0, W);
87 Estimates AAR parameters with Kalman filter algorithm
88 y(t) = sum_i(a_i(t)*y(t-i)) + m(t) + e(t) + sum_i(b_i(t)*e(t-i))
91 z(t) = G*z(t-1) + w(t) w(t)=N(0,W)
92 y(t) = H*z(t) + v(t) v(t)=N(0,V)
95 z = [m(t),a_1(t-1),..,a_p(t-p),b_1(t-1),...,b_q(t-q)];
96 H = [1,y(t-1),..,y(t-p),e(t-1),...,e(t-q)];
97 W = E{(z(t)-G*z(t-1))*(z(t)-G*z(t-1))'}
98 V = E{(y(t)-H*z(t-1))*(y(t)-H*z(t-1))'}
102 y Signal (AR-Process)
103 Mode determines the type of algorithm
105 MOP Model order [m,p,q], default [0,10,0]
106 m=1 includes the mean term, m=0 does not.
107 p and q must be positive integers
108 it is recommended to set q=0.
109 UC Update Coefficient, default 0
110 z0 Initial state vector
111 Z0 Initial Covariance matrix
115 E error process (Adaptively filtered process)
116 REV relative error variance MSE/MSY
119 [1] A. Schloegl (2000), The electroencephalogram and the adaptive autoregressive model: theory and applications.
120 ISBN 3-8265-7640-3 Shaker Verlag, Aachen, Germany.
122 More references can be found at
123 http://pub.ist.ac.at/~schloegl/publications/
127 # name: <cell-element>
131 Estimating Adaptive AutoRegressive-Moving-Average-and-mean model (includes mean
135 # name: <cell-element>
142 # name: <cell-element>
146 converts the autocorrelation sequence into an AR polynomial
147 [A,Efinal] = ac2poly(r)
149 see also ACOVF ACORF AR2RC RC2AR DURLEV AC2POLY, POLY2RC, RC2POLY, RC2AC, AC2RC, POLY2AC
154 # name: <cell-element>
158 converts the autocorrelation sequence into an AR polynomial
163 # name: <cell-element>
170 # name: <cell-element>
174 converts the autocorrelation function into reflection coefficients
177 see also ACOVF ACORF AR2RC RC2AR DURLEV AC2POLY, POLY2RC, RC2POLY, RC2AC, AC2RC, POLY2AC
182 # name: <cell-element>
186 converts the autocorrelation function into reflection coefficients
191 # name: <cell-element>
198 # name: <cell-element>
202 Calculates autocorrelations for multiple data series.
203 Missing values in Z (NaN) are considered.
204 Also calculates Ljung-Box Q stats and p-values.
206 [AutoCorr,stderr,lpq,qpval] = acorf(Z,N);
207 If mean should be removed use
208 [AutoCorr,stderr,lpq,qpval] = acorf(detrend(Z',0)',N);
209 If trend should be removed use
210 [AutoCorr,stderr,lpq,qpval] = acorf(detrend(Z')',N);
213 Z is data series for which autocorrelations are required
218 AutoCorr nr x N matrix of autocorrelations
219 stderr nr x N matrix of (approx) std errors
220 lpq nr x M matrix of Ljung-Box Q stats
221 qpval nr x N matrix of p-values on Q stats
223 All input and output parameters are organized in rows, one row
224 corresponds to one series
227 S. Haykin "Adaptive Filter Theory" 3ed. Prentice Hall, 1996.
228 M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
229 W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
230 J.S. Bendat and A.G.Persol "Random Data: Analysis and Measurement procedures", Wiley, 1986.
234 # name: <cell-element>
238 Calculates autocorrelations for multiple data series.
242 # name: <cell-element>
249 # name: <cell-element>
253 ACOVF estimates autocovariance function (not normalized)
254 NaN's are interpreted as missing values.
256 [ACF,NN] = acovf(Z,MAXLAG,Mode);
259 Z Signal (one channel per row);
261 Mode 'biased' : normalizes with N [default]
262 'unbiased': normalizes with N-lag
263 'coeff' : normalizes such that lag 0 is 1
264 others : no normalization
267 ACF autocovariance function
268 NN number of valid elements
271 A.V. Oppenheim and R.W. Schafer, Digital Signal Processing, Prentice-Hall, 1975.
272 S. Haykin "Adaptive Filter Theory" 3ed. Prentice Hall, 1996.
273 M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
274 W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
275 J.S. Bendat and A.G.Persol "Random Data: Analysis and Measurement procedures", Wiley, 1986.
279 # name: <cell-element>
283 ACOVF estimates autocovariance function (not normalized)
284 NaN's are interpreted
288 # name: <cell-element>
295 # name: <cell-element>
299 ADIM adaptive information matrix. Estimates the inverse
300 correlation matrix in an adaptive way.
302 [IR, CC] = adim(U, UC [, IR0 [, CC0]]);
304 UC update coefficient 0 < UC << 1
305 IR0 initial information matrix
306 CC0 initial correlation matrix
307 IR information matrix (inverse correlation matrix)
308 CC correlation matrix
310 The algorithm uses the Matrix Inversion Lemma, also known as
311 "Woodbury's identity", to obtain a recursive algorithm.
312 IR*CC - UC*I should be approx. zero.
315 [1] S. Haykin. Adaptive Filter Theory, Prentice Hall, Upper Saddle River, NJ, USA
316 pp. 565-567, Equ. (13.16), 1996.
320 # name: <cell-element>
324 ADIM adaptive information matrix.
328 # name: <cell-element>
335 # name: <cell-element>
339 Adaptive Mean-AutoRegressive-Moving-Average model estimation
340 [z,E,ESU,REV,V,Z,SPUR] = amarma(y, mode, MOP, UC, z0, Z0, V0, W);
341 Estimates AAR parameters with Kalman filter algorithm
342 y(t) = sum_i(a(i,t)*y(t-i)) + mu(t) + E(t)
345 z(t)=G*z(t-1) + w(t) w(t)=N(0,W)
346 y(t)=H*z(t) + v(t) v(t)=N(0,V)
349 z = [µ(t)/(1-sum_i(a(i,t))),a_1(t-1),..,a_p(t-p),b_1(t-1),...,b_q(t-q)];
350 H = [1,y(t-1),..,y(t-p),e(t-1),...,e(t-q)];
351 W = E{(z(t)-G*z(t-1))*(z(t)-G*z(t-1))'}
352 V = E{(y(t)-H*z(t-1))*(y(t)-H*z(t-1))'}
355 y Signal (AR-Process)
359 MOP Model order [m,p,q], default [0,10,0]
360 m=1 includes the mean term, m=0 does not.
361 p and q must be positive integers
362 it is recommended to set q=0.
363 UC Update Coefficient, default 0
364 z0 Initial state vector
365 Z0 Initial Covariance matrix
369 E error process (Adaptively filtered process)
370 REV relative error variance MSE/MSY
376 [1] A. Schloegl (2000), The electroencephalogram and the adaptive autoregressive model: theory and applications.
377 ISBN 3-8265-7640-3 Shaker Verlag, Aachen, Germany.
378 [2] Schlögl A, Lee FY, Bischof H, Pfurtscheller G
379 Characterization of Four-Class Motor Imagery EEG Data for the BCI-Competition 2005.
380 Journal of neural engineering 2 (2005) 4, S. L14-L22
382 More references can be found at
383 http://www.dpmi.tu-graz.ac.at/~schloegl/publications/
387 # name: <cell-element>
391 Adaptive Mean-AutoRegressive-Moving-Average model estimation
396 # name: <cell-element>
403 # name: <cell-element>
407 converts autoregressive parameters into AR polymials
408 Multiple polynomials can be converted.
409 function [A] = ar2poly(AR);
412 AR AR parameters, each row represents one set of AR parameters
415 A denominator polynom
418 see also ACOVF ACORF DURLEV RC2AR FILTER FREQZ ZPLANE
421 P.J. Brockwell and R. A. Davis "Time Series: Theory and Methods", 2nd ed. Springer, 1991.
422 S. Haykin "Adaptive Filter Theory" 3rd ed. Prentice Hall, 1996.
423 M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
424 W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
428 # name: <cell-element>
432 converts autoregressive parameters into AR polymials
433 Multiple polynomials can
437 # name: <cell-element>
444 # name: <cell-element>
448 converts autoregressive parameters into reflection coefficients
449 with the Durbin-Levinson recursion for multiple channels
450 function [AR,RC,PE] = ar2rc(AR);
451 function [MX,PE] = ar2rc(AR);
454 AR autoregressive model parameter
457 AR autoregressive model parameter
458 RC reflection coefficients (= -PARCOR coefficients)
459 PE remaining error variance (relative to PE(1)=1)
460 MX transformation matrix between ARP and RC (Attention: needs O(p^2) memory)
461 AR = MX(:,K*(K-1)/2+(1:K));
462 RC = MX(:,(1:K).*(2:K+1)/2);
464 All input and output parameters are organized in rows, one row
465 corresponds to the parameters of one channel
467 see also ACOVF ACORF DURLEV RC2AR
470 P.J. Brockwell and R. A. Davis "Time Series: Theory and Methods", 2nd ed. Springer, 1991.
471 S. Haykin "Adaptive Filter Theory" 3rd ed. Prentice Hall, 1996.
472 M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
473 W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
477 # name: <cell-element>
481 converts autoregressive parameters into reflection coefficients
486 # name: <cell-element>
493 # name: <cell-element>
497 AR_SPA decomposes an AR-spectrum into its compontents
498 [w,A,B,R,P,F,ip] = ar_spa(AR,fs,E);
501 AR autoregressive parameters
502 fs sampling rate, provide w and B in [Hz], if not given the result is in radians
503 E noise level (mean square), gives A and F in units of E, if not given as relative amplitude
509 - less important output parameters -
512 ip number of complex conjugate poles
513 real(F) power, absolute values are obtained by multiplying with noise variance E(p+1)
514 imag(F) assymetry, - " -
516 All input and output parameters are organized in rows, one row
517 corresponds to the parameters of one channel
519 see also ACOVF ACORF DURLEV IDURLEV PARCOR YUWA
522 [1] Zetterberg L.H. (1969) Estimation of parameter for linear difference equation with application to EEG analysis. Math. Biosci., 5, 227-275.
523 [2] Isaksson A. and Wennberg, A. (1975) Visual evaluation and computer analysis of the EEG - A comparison. Electroenceph. clin. Neurophysiol., 38: 79-86.
524 [3] G. Florian and G. Pfurtscheller (1994) Autoregressive model based spectral analysis with application to EEG. IIG - Report Series, University of Technolgy Graz, Austria.
528 # name: <cell-element>
532 AR_SPA decomposes an AR-spectrum into its compontents
533 [w,A,B,R,P,F,ip] = ar_s
537 # name: <cell-element>
544 # name: <cell-element>
548 ARCEXT extracts AR and RC of order P from Matrix MX
549 function [AR,RC] = arcext(MX,P);
552 MX AR and RC matrix calculated by durlev
553 P model order (default maximum possible)
556 AR autoregressive model parameter
557 RC reflection coefficients (= -PARCOR coefficients)
559 All input and output parameters are organized in rows, one row
560 corresponds to the parameters of one channel
562 see also ACOVF ACORF DURLEV
565 P.J. Brockwell and R. A. Davis "Time Series: Theory and Methods", 2nd ed. Springer, 1991.
566 S. Haykin "Adaptive Filter Theory" 3rd ed. Prentice Hall, 1996.
567 M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
568 W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
572 # name: <cell-element>
576 ARCEXT extracts AR and RC of order P from Matrix MX
577 function [AR,RC] = arcext
581 # name: <cell-element>
588 # name: <cell-element>
592 ARFIT2 estimates multivariate autoregressive parameters
593 of the MVAR process Y
595 Y(t,:)' = w' + A1*Y(t-1,:)' + ... + Ap*Y(t-p,:)' + x(t,:)'
597 ARFIT2 uses the Nutall-Strand method (multivariate Burg algorithm)
598 which provides better estimates the ARFIT [1], and uses the
599 same arguments. Moreover, ARFIT2 is faster and can deal with
600 missing values encoded as NaNs.
602 [w, A, C, sbc, fpe] = arfit2(v, pmin, pmax, selector, no_const)
605 v data - each channel in a column
606 pmin, pmax minimum and maximum model order
607 selector 'fpe' or 'sbc' [default]
608 no_const 'zero' indicates no bias/offset need to be estimated
609 in this case is w = [0, 0, ..., 0]';
612 w mean of innovation noise
613 A [A1,A2,...,Ap] MVAR estimates
614 C covariance matrix of innovation noise
615 sbc, fpe criteria for model order selection
617 see also: ARFIT, MVAR
620 [1] A. Schloegl, 2006, Comparison of Multivariate Autoregressive Estimators.
621 Signal processing, p. 2426-9.
622 [2] T. Schneider and A. Neumaier, 2001.
623 Algorithm 808: ARFIT-a Matlab package for the estimation of parameters and eigenmodes
624 of multivariate autoregressive models. ACM-Transactions on Mathematical Software. 27, (Mar.), 58-65.
628 # name: <cell-element>
632 ARFIT2 estimates multivariate autoregressive parameters
633 of the MVAR process Y
638 # name: <cell-element>
645 # name: <cell-element>
649 BiAutoCovariance function
650 [BiACF] = biacovf(Z,N);
654 Output: BIACF bi-autocorrelation function (joint cumulant 3rd order
655 Output: ACF covariance function (joint cumulant 2nd order)
659 # name: <cell-element>
663 BiAutoCovariance function
664 [BiACF] = biacovf(Z,N);
669 # name: <cell-element>
676 # name: <cell-element>
680 BISDEMO (script) Shows BISPECTRUM of eeg8s.mat
684 # name: <cell-element>
688 BISDEMO (script) Shows BISPECTRUM of eeg8s.
692 # name: <cell-element>
699 # name: <cell-element>
703 Calculates Bispectrum
704 [BISPEC] = bispec(Z,N);
708 Output: BiACF bi-autocorrelation function = 3rd order cumulant
712 C.L. Nikias and A.P. Petropulu "Higher-Order Spectra Analysis" Prentice Hall, 1993.
713 M.B. Priestley, "Non-linear and Non-stationary Time series Analysis", Academic Press, London, 1988.
717 # name: <cell-element>
721 Calculates Bispectrum
722 [BISPEC] = bispec(Z,N);
727 # name: <cell-element>
734 # name: <cell-element>
738 Time Series Analysis (Ver 3.10)
739 Schloegl A. (1996-2003,2008) Time Series Analysis - A Toolbox for the use with Matlab.
740 WWW: http://hci.tugraz.at/~schloegl/matlab/tsa/
742 $Id: content.m 5090 2008-06-05 08:12:04Z schloegl $
743 Copyright (C) 1996-2003,2008 by Alois Schloegl <a.schloegl@ieee.org>
745 Time Series Analysis - a toolbox for the use with Matlab
746 aar adaptive autoregressive estimator
747 acovf (*) Autocovariance function
748 acorf (acf) (*) autocorrelation function
749 pacf (*) partial autocorrelation function, includes signifcance test and confidence interval
750 parcor (*) partial autocorrelation function
751 biacovf biautocovariance function (3rd order cumulant)
753 durlev (*) solves Yule-Walker equation - converts ACOVF into AR parameters
754 lattice (*) calcultes AR parameters with lattice method
755 lpc (*) calculates the prediction coefficients form a given time series
756 invest0 (*) a prior investigation (used by invest1)
757 invest1 (*) investigates signal (useful for 1st evaluation of the data)
758 selmo (*) Select Order of Autoregressive model using different criteria
760 hup (*) test Hurwitz polynomials
761 ucp (*) test Unit Circle Polynomials
762 y2res (*) computes mean, variance, skewness, kurtosis, entropy, etc. from data series
763 ar_spa (*) spectral analysis based on the autoregressive model
764 detrend (*) removes trend, can handle missing values, non-equidistant sampled data
765 flix floating index, interpolates data for non-interger indices
766 quantiles calculates quantiles
768 Multivariate analysis (planned in future)
769 mvar multivariate (vector) autoregressive estimation
770 mvfilter multivariate filter
771 arfit2 provides compatibility to ARFIT [Schneider and Neumaier, 2001]
775 # name: <cell-element>
779 Time Series Analysis (Ver 3.
783 # name: <cell-element>
790 # name: <cell-element>
794 Time Series Analysis - A toolbox for the use with Matlab and Octave.
796 $Id: contents.m 5090 2008-06-05 08:12:04Z schloegl $
797 Copyright (C) 1996-2004,2008 by Alois Schloegl <a.schloegl@ieee.org>
798 WWW: http://hci.tugraz.at/~schloegl/matlab/tsa/
800 This program is free software: you can redistribute it and/or modify
801 it under the terms of the GNU General Public License as published by
802 the Free Software Foundation, either version 3 of the License, or
803 (at your option) any later version.
805 This program is distributed in the hope that it will be useful,
806 but WITHOUT ANY WARRANTY; without even the implied warranty of
807 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
808 GNU General Public License for more details.
810 You should have received a copy of the GNU General Public License
811 along with this program. If not, see <http://www.gnu.org/licenses/>.
814 Time Series Analysis - a toolbox for the use with Matlab
815 aar adaptive autoregressive estimator
816 acovf (*) Autocovariance function
817 acorf (acf) (*) autocorrelation function
818 pacf (*) partial autocorrelation function, includes signifcance test and confidence interval
819 parcor (*) partial autocorrelation function
820 biacovf biautocovariance function (3rd order cumulant)
822 durlev (*) solves Yule-Walker equation - converts ACOVF into AR parameters
823 lattice (*) calcultes AR parameters with lattice method
824 lpc (*) calculates the prediction coefficients form a given time series
825 invest0 (*) a prior investigation (used by invest1)
826 invest1 (*) investigates signal (useful for 1st evaluation of the data)
827 rmle AR estimation using recursive maximum likelihood function
828 selmo (*) Select Order of Autoregressive model using different criteria
830 hup (*) test Hurwitz polynomials
831 ucp (*) test Unit Circle Polynomials
832 y2res (*) computes mean, variance, skewness, kurtosis, entropy, etc. from data series
833 ar_spa (*) spectral analysis based on the autoregressive model
834 detrend (*) removes trend, can handle missing values, non-equidistant sampled data
835 flix floating index, interpolates data for non-interger indices
838 Multivariate analysis
839 adim adaptive information matrix (inverse correlation matrix)
840 mvar multivariate (vector) autoregressive estimation
841 mvaar multivariate adaptvie autoregressive estimation using Kalman filtering
842 mvfilter multivariate filter
843 mvfreqz multivariate spectra
844 arfit2 provides compatibility to ARFIT [Schneider and Neumaier, 2001]
847 Conversions between Autocorrelation (AC), Autoregressive parameters (AR),
848 prediction polynom (POLY) and Reflection coefficient (RC)
849 ac2poly (*) transforms autocorrelation into prediction polynom
850 ac2rc (*) transforms autocorrelation into reflexion coefficients
851 ar2rc (*) transforms autoregressive parameters into reflection coefficients
852 rc2ar (*) transforms reflection coefficients into autoregressive parameters
853 poly2ac (*) transforms polynom to autocorrelation
854 poly2ar (*) transforms polynom to AR
861 sinvest1 shows the parameter calculated by INVEST1
864 tsademo demonstrates INVEST1 on EEG data
865 invfdemo demonstration of matched, inverse filtering
866 bisdemo demonstrates bispectral estimation
868 (*) indicates univariate analysis of multiple data series (each in a row) can be processed.
869 (-) indicates that these functions will be removed in future
871 REFERENCES (sources):
872 http://www.itl.nist.gov/
873 http://mathworld.wolfram.com/
874 P.J. Brockwell and R.A. Davis "Time Series: Theory and Methods", 2nd ed. Springer, 1991.
875 O. Foellinger "Lineare Abtastsysteme", Oldenburg Verlag, Muenchen, 1986.
876 F. Gausch "Systemtechnik", Textbook, University of Technology Graz, 1993.
877 M.S. Grewal and A.P. Andrews "Kalman Filtering" Prentice Hall, 1993.
878 S. Haykin "Adaptive Filter Theory" 3ed. Prentice Hall, 1996.
879 E.I. Jury "Theory and Application of the z-Transform Method", Robert E. Krieger Publishing Co., 1973.
880 M.S. Kay "Modern Spectal Estimation" Prentice Hall, 1988.
881 Ch. Langraf and G. Schneider "Elemente der Regeltechnik", Springer Verlag, 1970.
882 S.L. Marple "Digital Spetral Analysis with Applications" Prentice Hall, 1987.
883 C.L. Nikias and A.P. Petropulu "Higher-Order Spectra Analysis" Prentice Hall, 1993.
884 M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
885 T. Schneider and A. Neumaier "Algorithm 808: ARFIT - a matlab package for the estimation of parameters and eigenmodes of multivariate autoregressive models"
886 ACM Transactions on Mathematical software, 27(Mar), 58-65.
887 C.E. Shannon and W. Weaver "The mathematical theory of communication" University of Illinois Press, Urbana 1949 (reprint 1963).
888 W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
891 REFERENCES (applications):
892 [1] A. Schlögl, B. Kemp, T. Penzel, D. Kunz, S.-L. Himanen,A. Värri, G. Dorffner, G. Pfurtscheller.
893 Quality Control of polysomnographic Sleep Data by Histogram and Entropy Analysis.
894 Clin. Neurophysiol. 1999, Dec; 110(12): 2165 - 2170.
895 [2] Penzel T, Kemp B, Klösch G, Schlögl A, Hasan J, Varri A, Korhonen I.
896 Acquisition of biomedical signals databases
897 IEEE Engineering in Medicine and Biology Magazine 2001, 20(3): 25-32
898 [3] Alois Schlögl (2000)
899 The electroencephalogram and the adaptive autoregressive model: theory and applications
900 Shaker Verlag, Aachen, Germany,(ISBN3-8265-7640-3).
903 - Multiple Signal Processing
904 - Efficient algorithms
905 - Model order selection tools
906 - higher (3rd) order analysis
907 - Maximum entropy spectral estimation
908 - can deal with missing values (NaN's)
912 # name: <cell-element>
916 Time Series Analysis - A toolbox for the use with Matlab and Octave.
920 # name: <cell-element>
927 # name: <cell-element>
931 COVM generates covariance matrix
932 X and Y can contain missing values encoded with NaN.
933 NaN's are skipped, NaN do not result in a NaN output.
934 The output gives NaN only if there are insufficient input data
937 calculates the (auto-)correlation matrix of X
939 calculates the crosscorrelation between X and Y
941 weighted crosscorrelation
943 Mode = 'M' minimum or standard mode [default]
944 C = X'*X; or X'*Y correlation matrix
946 Mode = 'E' extended mode
947 C = [1 X]'*[1 X]; % l is a matching column of 1's
948 C is additive, i.e. it can be applied to subsequent blocks and summed up afterwards
949 the mean (or sum) is stored on the 1st row and column of C
951 Mode = 'D' or 'D0' detrended mode
952 the mean of X (and Y) is removed. If combined with extended mode (Mode='DE'),
953 the mean (or sum) is stored in the 1st row and column of C.
954 The default scaling is factor (N-1).
955 Mode = 'D1' is the same as 'D' but uses N for scaling.
958 C is the scaled by N in Mode M and by (N-1) in mode D.
960 C is not scaled, provides the scaling factor N
961 C./N gives the scaled version.
963 see also: DECOVM, XCOVF
967 # name: <cell-element>
971 COVM generates covariance matrix
972 X and Y can contain missing values encoded wi
976 # name: <cell-element>
983 # name: <cell-element>
987 DETREND removes the trend from data, NaN's are considered as missing values
989 DETREND is fully compatible to previous Matlab and Octave DETREND with the following features added:
990 - handles NaN's by assuming that these are missing values
991 - handles unequally spaced data
992 - second output parameter gives the trend of the data
993 - compatible to Matlab and Octave
995 [...]=detrend([t,] X [,p])
996 removes trend for unequally spaced data
997 t represents the time points
998 X(i) is the value at time t(i)
1002 [...]=detrend(X,'constant')
1006 removes polynomial of order p (default p=1)
1008 [...]=detrend(X,1) - default
1009 [...]=detrend(X,'linear')
1010 removes linear trend
1014 X is the detrended data
1015 T is the removed trend
1017 see also: SUMSKIPNAN, ZSCORE
1021 # name: <cell-element>
1025 DETREND removes the trend from data, NaN's are considered as missing values
1031 # name: <cell-element>
1038 # name: <cell-element>
1042 function [AR,RC,PE] = durlev(ACF);
1043 function [MX,PE] = durlev(ACF);
1044 estimates AR(p) model parameter by solving the
1045 Yule-Walker with the Durbin-Levinson recursion
1046 for multiple channels
1048 ACF Autocorrelation function from lag=[0:p]
1051 AR autoregressive model parameter
1052 RC reflection coefficients (= -PARCOR coefficients)
1053 PE remaining error variance
1054 MX transformation matrix between ARP and RC (Attention: needs O(p^2) memory)
1055 AR(:,K) = MX(:,K*(K-1)/2+(1:K));
1056 RC(:,K) = MX(:,(1:K).*(2:K+1)/2);
1058 All input and output parameters are organized in rows, one row
1059 corresponds to the parameters of one channel
1061 see also ACOVF ACORF AR2RC RC2AR LATTICE
1064 Levinson N. (1947) "The Wiener RMS(root-mean-square) error criterion in filter design and prediction." J. Math. Phys., 25, pp.261-278.
1065 Durbin J. (1960) "The fitting of time series models." Rev. Int. Stat. Inst. vol 28., pp 233-244.
1066 P.J. Brockwell and R. A. Davis "Time Series: Theory and Methods", 2nd ed. Springer, 1991.
1067 S. Haykin "Adaptive Filter Theory" 3rd ed. Prentice Hall, 1996.
1068 M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
1069 W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
1073 # name: <cell-element>
1077 function [AR,RC,PE] = durlev(ACF);
1078 function [MX,PE] = durlev(ACF);
1083 # name: <cell-element>
1087 flag_implicit_samplerate
1090 # name: <cell-element>
1094 The use of FLAG_IMPLICIT_SAMPLERATE is in experimental state.
1095 FLAG_IMPLICIT_SAMPLERATE might even become obsolete.
1100 # name: <cell-element>
1104 The use of FLAG_IMPLICIT_SAMPLERATE is in experimental state.
1108 # name: <cell-element>
1112 flag_implicit_skip_nan
1115 # name: <cell-element>
1119 FLAG_IMPLICIT_SKIP_NAN sets and gets default mode for handling NaNs
1120 1 skips NaN's (the default mode if no mode is set)
1121 0 NaNs are propagated; input NaN's give NaN's at the output
1123 FLAG = flag_implicit_skip_nan()
1126 flag_implicit_skip_nan(FLAG)
1129 prevFLAG = flag_implicit_skip_nan(nextFLAG)
1130 gets previous set FLAG and sets FLAG for the future
1131 flag_implicit_skip_nan(prevFLAG)
1132 resets FLAG to previous mode
1135 SUMSKIPNAN, MEDIAN, QUANTILES, TRIMEAN
1136 and affects many other functions like:
1137 CENTER, KURTOSIS, MAD, MEAN, MOMENT, RMS, SEM, SKEWNESS,
1138 STATISTIC, STD, VAR, ZSCORE etc.
1140 The mode is stored in the global variable FLAG_implicit_skip_nan
1141 It is recommended to use flag_implicit_skip_nan(1) as default and
1142 flag_implicit_skip_nan(0) should be used for exceptional cases only.
1143 This feature might disappear without further notice, so you should really not
1148 # name: <cell-element>
1152 FLAG_IMPLICIT_SKIP_NAN sets and gets default mode for handling NaNs
1157 # name: <cell-element>
1164 # name: <cell-element>
1168 floating point index - interpolates data in case of non-integer indices
1171 FLIX returns Y=D(x) if x is an integer
1172 otherwise D(x) is interpolated from the neighbors D(ceil(x)) and D(floor(x))
1175 (1) discrete Dataseries can be upsampled to higher sampling rate
1176 (2) transformation of non-equidistant samples to equidistant samples
1177 (3) [Q]=flix(sort(D),q*(length(D)+1)) calculates the q-quantile of data series D
1179 FLIX(D,x) is the same as INTERP1(D,X,'linear'); Therefore, FLIX might
1180 become obsolete in future.
1182 see also: HIST2RES, Y2RES, PLOTCDF, INTERP1
1186 # name: <cell-element>
1190 floating point index - interpolates data in case of non-integer indices
1195 # name: <cell-element>
1202 # name: <cell-element>
1206 HISTO calculates histogram for each column
1207 [H,X] = HISTO(Y,Mode)
1210 'rows' : frequency of each row
1211 '1x' : single bin-values
1212 'nx' : separate bin-values for each column
1213 X are the bin-values
1214 H is the frequency of occurence of value X
1216 HISTO(Y) with no output arguments:
1217 plots the histogram bar(X,H)
1219 more histogram-based results can be obtained by HIST2RES2
1221 see also: HISTO, HISTO2, HISTO3, HISTO4
1224 C.E. Shannon and W. Weaver "The mathematical theory of communication" University of Illinois Press, Urbana 1949 (reprint 1963).
1228 # name: <cell-element>
1232 HISTO calculates histogram for each column
1233 [H,X] = HISTO(Y,Mode)
1239 # name: <cell-element>
1246 # name: <cell-element>
1250 HISTO2 calculates histogram for multiple columns with separate bin values
1251 for each data column.
1256 W weight vector containing weights of each sample,
1257 number of rows of Y and W must match.
1258 default W=[] indicates that each sample is weighted with 1.
1261 R is a struct with th fields
1262 R.X the bin-values, bin-values are computed separately for each
1263 data column, thus R.X is a matrix, each column contains the
1264 the bin values of for each data column, unused elements are indicated with NaN.
1265 In order to have common bin values, use HISTO3.
1266 R.H is the frequency of occurence of value X
1267 R.N are the number of valid (not NaN) samples (i.e. sum of weights)
1269 more histogram-based results can be obtained by HIST2RES2
1271 see also: HISTO, HISTO2, HISTO3, HISTO4
1274 C.E. Shannon and W. Weaver "The mathematical theory of communication" University of Illinois Press, Urbana 1949 (reprint 1963).
1278 # name: <cell-element>
1282 HISTO2 calculates histogram for multiple columns with separate bin values
1287 # name: <cell-element>
1294 # name: <cell-element>
1298 HISTO3 calculates histogram for multiple columns with common bin values
1299 among all data columns, and can be useful for data compression.
1304 W weight vector containing weights of each sample,
1305 number of rows of Y and W must match.
1306 default W=[] indicates that each sample is weighted with 1.
1307 R struct with these fields
1308 R.X the bin-values, bin-values are equal for each channel
1309 thus R.X is a column vector. If bin values should
1310 be computed separately for each data column, use HISTO2
1311 R.H is the frequency of occurence of value X
1312 R.N are the number of valid (not NaN) samples
1314 Data compression can be performed in this way
1316 is the compression step
1318 R.tix provides a compressed data representation.
1319 R.compressionratio estimates the compression ratio
1321 R.X(tix) and R.X(R.tix)
1322 reconstruct the orginal signal (decompression)
1324 The effort (in memory and speed) for compression is O(n*log(n)).
1325 The effort (in memory and speed) for decompression is O(n) only.
1327 see also: HISTO, HISTO2, HISTO3, HISTO4
1330 C.E. Shannon and W. Weaver "The mathematical theory of communication" University of Illinois Press, Urbana 1949 (reprint 1963).
1334 # name: <cell-element>
1338 HISTO3 calculates histogram for multiple columns with common bin values
1343 # name: <cell-element>
1350 # name: <cell-element>
1354 HISTO4 calculates histogram of multidimensional data samples
1355 and supports data compression
1359 Y data: on sample per row, each sample has with size(Y,2) elements
1360 W weights of each sample (default: [])
1361 W = [] indicates that each sample has equal weight
1362 R is a struct with these fields:
1363 R.X are the bin-values
1364 R.H is the frequency of occurence of value X (weighted with W)
1365 R.N are the total number of samples (or sum of W)
1367 HISTO4 might be useful for data compression, because
1369 is the compression step
1371 is the decompression step
1373 The effort (in memory and speed) for compression is O(n*log(n))
1374 The effort (in memory and speed) for decompression is only O(n)
1376 see also: HISTO, HISTO2, HISTO3, HISTO4
1379 C.E. Shannon and W. Weaver 'The mathematical theory of communication' University of Illinois Press, Urbana 1949 (reprint 1963).
1383 # name: <cell-element>
1387 HISTO4 calculates histogram of multidimensional data samples
1392 # name: <cell-element>
1399 # name: <cell-element>
1403 HUP(C) tests if the polynomial C is a Hurwitz-Polynomial.
1404 It tests if all roots lie in the left half of the complex
1406 B=hup(C) is the same as
1407 B=all(real(roots(c))<0) but much faster.
1408 The Algorithm is based on the Routh-Scheme.
1409 C are the elements of the Polynomial
1410 C(1)*X^N + ... + C(N)*X + C(N+1).
1412 HUP2 works also for multiple polynomials,
1413 each row a poly - Yet not tested
1416 F. Gausch "Systemtechnik", Textbook, University of Technology Graz, 1993.
1417 Ch. Langraf and G. Schneider "Elemente der Regeltechnik", Springer Verlag, 1970.
1421 # name: <cell-element>
1425 HUP(C) tests if the polynomial C is a Hurwitz-Polynomial.
1429 # name: <cell-element>
1436 # name: <cell-element>
1440 First Investigation of a signal (time series) - automated part
1441 [AutoCov,AutoCorr,ARPMX,E,ACFsd,NC]=invest0(Y,Pmax);
1443 [AutoCov,AutoCorr,ARPMX,E,ACFsd,NC]=invest0(AutoCov,Pmax,Mode);
1447 Pmax maximal order (optional)
1449 AutoCov Autocorrelation
1450 AutoCorr normalized Autocorrelation
1451 PartACF Partial Autocorrelation
1452 ARPMX Autoregressive Parameter for order Pmax-1
1453 E Error function E(p)
1454 NC Number of values (length-missing values)
1457 P.J. Brockwell and R.A. Davis "Time Series: Theory and Methods", 2nd ed. Springer, 1991.
1458 M.S. Grewal and A.P. Andrews "Kalman Filtering" Prentice Hall, 1993.
1459 S. Haykin "Adaptive Filter Theory" 3ed. Prentice Hall, 1996.
1460 M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
1461 W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
1465 # name: <cell-element>
1469 First Investigation of a signal (time series) - automated part
1474 # name: <cell-element>
1481 # name: <cell-element>
1485 First Investigation of a signal (time series) - interactive
1486 [AutoCov,AutoCorr,ARPMX,E,CRITERIA,MOPS]=invest1(Y,Pmax,show);
1489 Pmax maximal order (optional)
1490 show optional; if given the parameters are shown
1492 AutoCov Autocorrelation
1493 AutoCorr normalized Autocorrelation
1494 PartACF Partial Autocorrelation
1495 E Error function E(p)
1496 CRITERIA curves of the various (see below) criteria,
1497 MOPS=[optFPE optAIC optBIC optSBC optMDL optCAT optPHI];
1498 optimal model order according to various criteria
1500 FPE Final Prediction Error (Kay, 1987)
1501 AIC Akaike Information Criterion (Marple, 1987)
1502 BIC Bayesian Akaike Information Criterion (Wei, 1994)
1503 SBC Schwartz's Bayesian Criterion (Wei, 1994)
1504 MDL Minimal Description length Criterion (Marple, 1987)
1505 CAT Parzen's CAT Criterion (Wei, 1994)
1506 PHI Phi criterion (Pukkila et al. 1988)
1507 minE order where E is minimal
1510 P.J. Brockwell and R.A. Davis "Time Series: Theory and Methods", 2nd ed. Springer, 1991.
1511 S. Haykin "Adaptive Filter Theory" 3ed. Prentice Hall, 1996.
1512 M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
1513 C.E. Shannon and W. Weaver "The mathematical theory of communication" University of Illinois Press, Urbana 1949 (reprint 1963).
1514 W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
1518 # name: <cell-element>
1522 First Investigation of a signal (time series) - interactive
1527 # name: <cell-element>
1534 # name: <cell-element>
1538 invfdemo demonstrates Inverse Filtering
1542 # name: <cell-element>
1546 invfdemo demonstrates Inverse Filtering
1551 # name: <cell-element>
1558 # name: <cell-element>
1562 Estimates AR(p) model parameter with lattice algorithm (Burg 1968)
1563 for multiple channels.
1564 If you have the NaN-tools, LATTICE.M can handle missing values (NaN),
1566 [...] = lattice(y [,Pmax [,Mode]]);
1568 [AR,RC,PE] = lattice(...);
1569 [MX,PE] = lattice(...);
1572 y signal (one per row), can contain missing values (encoded as NaN)
1573 Pmax max. model order (default size(y,2)-1))
1574 Mode 'BURG' (default) Burg algorithm
1575 'GEOL' geometric lattice
1578 AR autoregressive model parameter
1579 RC reflection coefficients (= -PARCOR coefficients)
1580 PE remaining error variance
1581 MX transformation matrix between ARP and RC (Attention: needs O(p^2) memory)
1582 AR(:,K) = MX(:, K*(K-1)/2+(1:K)); = MX(:,sum(1:K-1)+(1:K));
1583 RC(:,K) = MX(:,cumsum(1:K)); = MX(:,(1:K).*(2:K+1)/2);
1585 All input and output parameters are organized in rows, one row
1586 corresponds to the parameters of one channel
1588 see also ACOVF ACORF AR2RC RC2AR DURLEV SUMSKIPNAN
1591 J.P. Burg, "Maximum Entropy Spectral Analysis" Proc. 37th Meeting of the Society of Exp. Geophysiscists, Oklahoma City, OK 1967
1592 J.P. Burg, "Maximum Entropy Spectral Analysis" PhD-thesis, Dept. of Geophysics, Stanford University, Stanford, CA. 1975.
1593 P.J. Brockwell and R. A. Davis "Time Series: Theory and Methods", 2nd ed. Springer, 1991.
1594 S. Haykin "Adaptive Filter Theory" 3rd ed. Prentice Hall, 1996.
1595 M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
1596 W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
1600 # name: <cell-element>
1604 Estimates AR(p) model parameter with lattice algorithm (Burg 1968)
1609 # name: <cell-element>
1616 # name: <cell-element>
1620 LPC Linear prediction coefficients
1621 The Burg-method is used to estimate the prediction coefficients
1623 A = lpc(Y [,P]) finds the coefficients A=[ 1 A(2) ... A(N+1) ],
1624 of an Pth order forward linear predictor
1626 Xp(n) = -A(2)*X(n-1) - A(3)*X(n-2) - ... - A(N+1)*X(n-P)
1628 such that the sum of the squares of the errors
1630 err(n) = X(n) - Xp(n)
1632 is minimized. X can be a vector or a matrix. If X is a matrix
1633 containing a separate signal in each column, LPC returns a model
1634 estimate for each column in the rows of A. N specifies the order
1635 of the polynomial A(z).
1637 If you do not specify a value for P, LPC uses a default P = length(X)-1.
1640 see also ACOVF ACORF AR2POLY RC2AR DURLEV SUMSKIPNAN LATTICE
1645 # name: <cell-element>
1649 LPC Linear prediction coefficients
1650 The Burg-method is used to estimate the pr
1654 # name: <cell-element>
1661 # name: <cell-element>
1665 Multivariate (Vector) adaptive AR estimation base on a multidimensional
1666 Kalman filer algorithm. A standard VAR model (A0=I) is implemented. The
1667 state vector is defined as X=(A1|A2...|Ap) and x=vec(X')
1669 [x,e,Kalman,Q2] = mvaar(y,p,UC,mode,Kalman)
1671 The standard MVAR model is defined as:
1673 y(n)-A1(n)*y(n-1)-...-Ap(n)*y(n-p)=e(n)
1675 The dimension of y(n) equals s
1679 y Observed data or signal
1680 p prescribed maximum model order (default 1)
1681 UC update coefficient (default 0.001)
1682 mode update method of the process noise covariance matrix 0...4 ^
1683 correspond to S0...S4 (default 0)
1687 e prediction error of dimension s
1688 x state vector of dimension s*s*p
1689 Q2 measurement noise covariance matrix of dimension s x s
1694 # name: <cell-element>
1698 Multivariate (Vector) adaptive AR estimation base on a multidimensional
1703 # name: <cell-element>
1710 # name: <cell-element>
1714 MVAR estimates parameters of the Multi-Variate AutoRegressive model
1716 Y(t) = Y(t-1) * A1 + ... + Y(t-p) * Ap + X(t);
1718 Y(t) is a row vecter with M elements Y(t) = y(t,1:M)
1720 Several estimation algorithms are implemented, all estimators
1721 can handle data with missing values encoded as NaNs.
1723 [AR,RC,PE] = mvar(Y, p);
1724 [AR,RC,PE] = mvar(Y, p, Mode);
1730 Y Multivariate data series
1732 Mode determines estimation algorithm
1735 AR multivariate autoregressive model parameter
1736 RC reflection coefficients (= -PARCOR coefficients)
1737 PE remaining error variances for increasing model order
1738 PE(:,p*M+[1:M]) is the residual variance for model order p
1740 All input and output parameters are organized in columns, one column
1741 corresponds to the parameters of one channel.
1743 Mode determines estimation algorithm.
1744 1: Correlation Function Estimation method using biased correlation function estimation method
1745 also called the 'multichannel Yule-Walker' [1,2]
1746 6: Correlation Function Estimation method using unbiased correlation function estimation method
1748 2: Partial Correlation Estimation: Vieira-Morf [2] using unbiased covariance estimates.
1749 In [1] this mode was used and (incorrectly) denominated as Nutall-Strand.
1750 Its the DEFAULT mode; according to [1] it provides the most accurate estimates.
1751 5: Partial Correlation Estimation: Vieira-Morf [2] using biased covariance estimates.
1752 Yields similar results than Mode=2;
1754 3: buggy: Partial Correlation Estimation: Nutall-Strand [2] (biased correlation function)
1755 9: Partial Correlation Estimation: Nutall-Strand [2] (biased correlation function)
1756 7: Partial Correlation Estimation: Nutall-Strand [2] (unbiased correlation function)
1757 8: Least Squares w/o nans in Y(t):Y(t-p)
1760 13: modified BURGV -
1761 14: modified BURGV [4]
1762 15: Least Squares based on correlation matrix
1763 22: Modified Partial Correlation Estimation: Vieira-Morf [2,5] using unbiased covariance estimates.
1764 25: Modified Partial Correlation Estimation: Vieira-Morf [2,5] using biased covariance estimates.
1766 90,91,96: Experimental versions
1770 200+Mode: forward, past missing values are assumed zero
1771 300+Mode: backward, past missing values are assumed zero
1772 400+Mode: forward+backward, past missing values are assumed zero
1773 1200+Mode: forward, past missing values are replaced with predicted value
1774 1300+Mode: backward, 'past' missing values are replaced with predicted value
1775 1400+Mode: forward+backward, 'past' missing values are replaced with predicted value
1776 2200+Mode: forward, past missing values are replaced with predicted value + noise to prevent decaying
1777 2300+Mode: backward, past missing values are replaced with predicted value + noise to prevent decaying
1778 2400+Mode: forward+backward, past missing values are replaced with predicted value + noise to prevent decaying
1785 # name: <cell-element>
1789 MVAR estimates parameters of the Multi-Variate AutoRegressive model
1794 # name: <cell-element>
1801 # name: <cell-element>
1805 Multi-variate filter function
1808 [Y,Z] = MVFILTER(B,A,X,Z)
1810 Y = MVFILTER(B,A,X) filters the data in matrix X with the
1811 filter described by cell arrays A and B to create the filtered
1812 data Y. The filter is a 'Direct Form II Transposed'
1813 implementation of the standard difference equation:
1815 a0*Y(n) = b0*X(:,n) + b1*X(:,n-1) + ... + bq*X(:,n-q)
1816 - a1*Y(:,n-1) - ... - ap*Y(:,n-p)
1818 A=[a0,a1,a2,...,ap] and B=[b0,b1,b2,...,bq] must be matrices of
1819 size Mx((p+1)*M) and Mx((q+1)*M), respectively.
1820 a0,a1,...,ap, b0,b1,...,bq are matrices of size MxM
1821 a0 is usually the identity matrix I or must be invertible
1822 X should be of size MxN, if X has size NxM a warning
1823 is raised, and the output Y is also transposed.
1825 A simulated MV-AR process can be generiated with
1826 Y = mvfilter(eye(M), [eye(M),-AR],randn(M,N));
1828 A multivariate inverse filter can be realized with
1829 [AR,RC,PE] = mvar(Y,P);
1830 E = mvfilter([eye(M),-AR],eye(M),Y);
1832 see also: MVAR, FILTER
1836 # name: <cell-element>
1840 Multi-variate filter function
1845 # name: <cell-element>
1852 # name: <cell-element>
1856 MVFREQZ multivariate frequency response
1857 [S,h,PDC,COH,DTF,DC,pCOH,dDTF,ffDTF,pCOH2,PDCF,coh,GGC,Af,GPDC] = mvfreqz(B,A,C,f,Fs)
1858 [...] = mvfreqz(B,A,C,N,Fs)
1862 A, B multivariate polynomials defining the transfer function
1864 a0*Y(n) = b0*X(n) + b1*X(n-1) + ... + bq*X(n-q)
1865 - a1*Y(n-1) - ... - ap*Y(:,n-p)
1867 A=[a0,a1,a2,...,ap] and B=[b0,b1,b2,...,bq] must be matrices of
1868 size Mx((p+1)*M) and Mx((q+1)*M), respectively.
1870 C is the covariance of the input noise X (i.e. D'*D if D is the mixing matrix)
1871 N if scalar, N is the number of frequencies
1872 if N is a vector, N are the designated frequencies.
1873 Fs sampling rate [default 2*pi]
1875 A,B,C and D can by obtained from a multivariate time series
1876 through the following commands:
1877 [AR,RC,PE] = mvar(Y,P);
1878 M = size(AR,1); % number of channels
1881 C = PE(:,M*P+1:M*(P+1));
1883 Fs sampling rate in [Hz]
1884 (N number of frequencies for computing the spectrum, this will become OBSOLETE),
1885 f vector of frequencies (in [Hz])
1891 h transfer functions, abs(h.^2) is the non-normalized DTF [11]
1892 PDC partial directed coherence [2]
1893 DC directed coupling
1894 COH coherency (complex coherence) [5]
1895 DTF directed transfer function
1896 pCOH partial coherence
1897 dDTF direct Directed Transfer function
1898 ffDTF full frequency Directed Transfer Function
1899 pCOH2 partial coherence - alternative method
1900 GGC a modified version of Geweke's Granger Causality [Geweke 1982]
1901 !!! it uses a Multivariate AR model, and computes the bivariate GGC as in [Bressler et al 2007].
1902 This is not the same as using bivariate AR models and GGC as in [Bressler et al 2007]
1903 Af Frequency transform of A(z), abs(Af.^2) is the non-normalized PDC [11]
1904 PDCF Partial Directed Coherence Factor [2]
1905 GPDC Generalized Partial Directed Coherence [9,10]
1907 see also: FREQZ, MVFILTER, MVAR
1910 [1] H. Liang et al. Neurocomputing, 32-33, pp.891-896, 2000.
1911 [2] L.A. Baccala and K. Samashima, Biol. Cybern. 84,463-474, 2001.
1912 [3] A. Korzeniewska, et al. Journal of Neuroscience Methods, 125, 195-207, 2003.
1913 [4] Piotr J. Franaszczuk, Ph.D. and Gregory K. Bergey, M.D.
1914 Fast Algorithm for Computation of Partial Coherences From Vector Autoregressive Model Coefficients
1915 World Congress 2000, Chicago.
1916 [5] Nolte G, Bai O, Wheaton L, Mari Z, Vorbach S, Hallett M.
1917 Identifying true brain interaction from EEG data using the imaginary part of coherency.
1918 Clin Neurophysiol. 2004 Oct;115(10):2292-307.
1919 [6] Schlogl A., Supp G.
1920 Analyzing event-related EEG data with multivariate autoregressive parameters.
1921 (Eds.) C. Neuper and W. Klimesch,
1922 Progress in Brain Research: Event-related Dynamics of Brain Oscillations.
1923 Analysis of dynamics of brain oscillations: methodological advances. Elsevier.
1924 Progress in Brain Research 159, 2006, p. 135 - 147
1925 [7] Bressler S.L., Richter C.G., Chen Y., Ding M. (2007)
1926 Cortical fuctional network organization from autoregressive modelling of loal field potential oscillations.
1927 Statistics in Medicine, doi: 10.1002/sim.2935
1929 J.Am.Stat.Assoc., 77, 304-313.
1930 [9] L.A. Baccala, D.Y. Takahashi, K. Sameshima. (2006)
1931 Generalized Partial Directed Coherence.
1932 Submitted to XVI Congresso Brasileiro de Automatica, Salvador, Bahia.
1933 [10] L.A. Baccala, D.Y. Takahashi, K. Sameshima.
1934 Computer Intensive Testing for the Influence Between Time Series,
1935 Eds. B. Schelter, M. Winterhalder, J. Timmer:
1936 Handbook of Time Series Analysis - Recent Theoretical Developments and Applications
1939 On the evaluation of informatino flow in multivariate systems by the directed transfer function
1940 Biol. Cybern. 94: 469-482, 2006.
1944 # name: <cell-element>
1948 MVFREQZ multivariate frequency response
1949 [S,h,PDC,COH,DTF,DC,pCOH,dDTF,ffDTF,pC
1953 # name: <cell-element>
1960 # name: <cell-element>
1964 Partial Autocorrelation function
1965 [parcor,sig,cil,ciu] = pacf(Z,N);
1968 Z Signal, each row is analysed
1973 # name: <cell-element>
1977 Partial Autocorrelation function
1978 [parcor,sig,cil,ciu] = pacf(Z,N);
1983 # name: <cell-element>
1990 # name: <cell-element>
1994 estimates partial autocorrelation coefficients
1995 Multiple channels can be used (one per row).
1997 [PARCOR, AR, PE] = parcor(AutoCov); % calculates Partial autocorrelation, autoregressive coefficients and residual error variance from the Autocorrelation function.
1999 [PARCOR] = parcor(acovf(x,p)); % calculates the Partial Autocorrelation coefficients of the data series x up to order p
2002 AutoCov Autocorrelation function for lag=0:P
2005 AR autoregressive model parameter
2006 PARCOR partial correlation coefficients (= -reflection coefficients)
2007 PE remaining error variance
2009 All input and output parameters are organized in rows, one row
2010 corresponds to the parameters of one channel.
2011 The PARCOR coefficients are the negative reflection coefficients.
2012 A significance test is implemented in PACF.
2014 see also: PACF ACOVF ACORF DURLEV AC2RC
2017 P.J. Brockwell and R.A. Davis "Time Series: Theory and Methods", 2nd ed. Springer, 1991.
2018 S. Haykin "Adaptive Filter Theory" 3ed. Prentice Hall, 1996.
2019 M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
2020 W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
2024 # name: <cell-element>
2028 estimates partial autocorrelation coefficients
2029 Multiple channels can be used
2033 # name: <cell-element>
2040 # name: <cell-element>
2044 converts an AR polynomial into an autocorrelation sequence
2045 [R] = poly2ac(a [,efinal] );
2047 see also ACOVF ACORF AR2RC RC2AR DURLEV AC2POLY, POLY2RC, RC2POLY, RC2AC, AC2RC, POLY2AC
2052 # name: <cell-element>
2056 converts an AR polynomial into an autocorrelation sequence
2061 # name: <cell-element>
2068 # name: <cell-element>
2072 Converts AR polymials into autoregressive parameters.
2073 Multiple polynomials can be converted.
2075 function [AR] = poly2ar(A);
2078 A AR polynomial, each row represents one polynomial
2081 AR autoregressive model parameter
2083 see also ACOVF ACORF DURLEV RC2AR AR2POLY
2087 # name: <cell-element>
2091 Converts AR polymials into autoregressive parameters.
2095 # name: <cell-element>
2102 # name: <cell-element>
2106 converts AR-polynomial into reflection coefficients
2107 [RC,R0] = poly2rc(A [,Efinal])
2110 A AR polynomial, each row represents one polynomial
2111 Efinal is the final prediction error variance (default value 1)
2114 RC reflection coefficients
2115 R0 is the variance (autocovariance at lag=0) based on the
2119 see also ACOVF ACORF AR2RC RC2AR DURLEV AC2POLY, POLY2RC, RC2POLY, RC2AC, AC2RC, POLY2AC
2123 # name: <cell-element>
2127 converts AR-polynomial into reflection coefficients
2128 [RC,R0] = poly2rc(A [,Efin
2132 # name: <cell-element>
2139 # name: <cell-element>
2143 converts reflection coefficients to autocorrelation sequence
2146 see also ACOVF ACORF AR2RC RC2AR DURLEV AC2POLY, POLY2RC, RC2POLY, RC2AC, AC2RC, POLY2AC
2151 # name: <cell-element>
2155 converts reflection coefficients to autocorrelation sequence
2160 # name: <cell-element>
2167 # name: <cell-element>
2171 converts reflection coefficients into autoregressive parameters
2172 uses the Durbin-Levinson recursion for multiple channels
2173 function [AR,RC,PE,ACF] = rc2ar(RC);
2174 function [MX,PE] = rc2ar(RC);
2177 RC reflection coefficients
2180 AR autoregressive model parameter
2181 RC reflection coefficients (= -PARCOR coefficients)
2182 PE remaining error variance (relative to PE(1)=1)
2183 MX transformation matrix between ARP and RC (Attention: needs O(p^2) memory)
2184 arp=MX(:,K*(K-1)/2+(1:K));
2185 rc =MX(:,(1:K).*(2:K+1)/2);
2187 All input and output parameters are organized in rows, one row
2188 corresponds to the parameters of one channel
2190 see also ACOVF ACORF DURLEV AR2RC
2193 P.J. Brockwell and R. A. Davis "Time Series: Theory and Methods", 2nd ed. Springer, 1991.
2194 S. Haykin "Adaptive Filter Theory" 3rd ed. Prentice Hall, 1996.
2195 M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
2196 W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
2200 # name: <cell-element>
2204 converts reflection coefficients into autoregressive parameters
2209 # name: <cell-element>
2216 # name: <cell-element>
2220 converts reflection coefficients into an AR-polynomial
2221 [a,efinal] = rc2poly(K)
2223 see also ACOVF ACORF AR2RC RC2AR DURLEV AC2POLY, POLY2RC, RC2POLY, RC2AC, AC2RC, POLY2AC
2228 # name: <cell-element>
2232 converts reflection coefficients into an AR-polynomial
2233 [a,efinal] = rc2poly(K)
2237 # name: <cell-element>
2244 # name: <cell-element>
2248 RMLE estimates AR Parameters using the Recursive Maximum Likelihood
2249 Estimator according to [1]
2251 Use: [a,VAR]=rmle(x,p)
2253 x is a column vector of data
2254 p is the model order
2256 a is a vector with the AR parameters of the recursive MLE
2257 VAR is the excitation white noise variance estimate
2260 [1] Kay S.M., Modern Spectral Analysis - Theory and Applications.
2261 Prentice Hall, p. 232-233, 1988.
2266 # name: <cell-element>
2270 RMLE estimates AR Parameters using the Recursive Maximum Likelihood
2275 # name: <cell-element>
2282 # name: <cell-element>
2286 SBISPEC show BISPECTRUM
2290 # name: <cell-element>
2294 SBISPEC show BISPECTRUM
2299 # name: <cell-element>
2306 # name: <cell-element>
2310 Model order selection of an autoregrssive model
2311 [FPE,AIC,BIC,SBC,MDL,CAT,PHI,optFPE,optAIC,optBIC,optSBC,optMDL,optCAT,optPHI]=selmo(E,N);
2313 E Error function E(p)
2314 N length of the data set, that was used for calculating E(p)
2315 show optional; if given the parameters are shown
2317 FPE Final Prediction Error (Kay 1987, Wei 1990, Priestley 1981 -> Akaike 1969)
2318 AIC Akaike Information Criterion (Marple 1987, Wei 1990, Priestley 1981 -> Akaike 1974)
2319 BIC Bayesian Akaike Information Criterion (Wei 1990, Priestley 1981 -> Akaike 1978,1979)
2320 CAT Parzen's CAT Criterion (Wei 1994 -> Parzen 1974)
2321 MDL Minimal Description length Criterion (Marple 1987 -> Rissanen 1978,83)
2322 SBC Schwartz's Bayesian Criterion (Wei 1994; Schwartz 1978)
2323 PHI Phi criterion (Pukkila et al. 1988, Hannan 1980 -> Hannan & Quinn, 1979)
2324 HAR Haring G. (1975)
2325 JEW Jenkins and Watts (1968)
2327 optFPE order where FPE is minimal
2328 optAIC order where AIC is minimal
2329 optBIC order where BIC is minimal
2330 optSBC order where SBC is minimal
2331 optMDL order where MDL is minimal
2332 optCAT order where CAT is minimal
2333 optPHI order where PHI is minimal
2336 AIC > FPE > *MDL* > PHI > SBC > CAT ~ BIC
2339 P.J. Brockwell and R.A. Davis "Time Series: Theory and Methods", 2nd ed. Springer, 1991.
2340 S. Haykin "Adaptive Filter Theory" 3ed. Prentice Hall, 1996.
2341 M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
2342 C.E. Shannon and W. Weaver "The mathematical theory of communication" University of Illinois Press, Urbana 1949 (reprint 1963).
2343 W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
2344 Jenkins G.M. Watts D.G "Spectral Analysis and its applications", Holden-Day, 1968.
2345 G. Haring "Über die Wahl der optimalen Modellordnung bei der Darstellung von stationären Zeitreihen mittels Autoregressivmodell als Basis der Analyse von EEG - Biosignalen mit Hilfe eines Digitalrechners", Habilitationschrift - Technische Universität Graz, Austria, 1975.
2346 (1)"About selecting the optimal model at the representation of stationary time series by means of an autoregressive model as basis of the analysis of EEG - biosignals by means of a digital computer)"
2351 # name: <cell-element>
2355 Model order selection of an autoregrssive model
2356 [FPE,AIC,BIC,SBC,MDL,CAT,PHI,o
2360 # name: <cell-element>
2367 # name: <cell-element>
2371 SELMO2 - model order selection for univariate and multivariate
2372 autoregressive models
2377 Pmax maximum model order
2378 X.A, X.B, X.C parameters of AR model
2379 X.OPT... various optimization criteria
2381 see also: SELMO, MVAR,
2385 # name: <cell-element>
2389 SELMO2 - model order selection for univariate and multivariate
2394 # name: <cell-element>
2401 # name: <cell-element>
2405 SINVEST1 shows the parameters of a time series calculated by INVEST1
2406 only called by INVEST1
2410 # name: <cell-element>
2414 SINVEST1 shows the parameters of a time series calculated by INVEST1
2419 # name: <cell-element>
2426 # name: <cell-element>
2430 SUMSKIPNAN adds all non-NaN values.
2432 All NaN's are skipped; NaN's are considered as missing values.
2433 SUMSKIPNAN of NaN's only gives O; and the number of valid elements is return.
2434 SUMSKIPNAN is also the elementary function for calculating
2435 various statistics (e.g. MEAN, STD, VAR, RMS, MEANSQ, SKEWNESS,
2436 KURTOSIS, MOMENT, STATISTIC etc.) from data with missing values.
2437 SUMSKIPNAN implements the DIMENSION-argument for data with missing values.
2438 Also the second output argument return the number of valid elements (not NaNs)
2440 Y = sumskipnan(x [,DIM])
2441 [Y,N,SSQ] = sumskipnan(x [,DIM])
2442 [...] = sumskipnan(x, DIM, W)
2445 DIM dimension (default: [])
2446 empty DIM sets DIM to first non singleton dimension
2447 W weight vector for weighted sum, numel(W) must fit size(x,DIM)
2449 N number of valid (not missing) elements
2452 the function FLAG_NANS_OCCURED() returns whether any value in x
2453 is a not-a-number (NaN)
2456 - can deal with NaN's (missing values)
2457 - implements dimension argument.
2458 - computes weighted sum
2459 - compatible with Matlab and Octave
2461 see also: FLAG_NANS_OCCURED, SUM, NANSUM, MEAN, STD, VAR, RMS, MEANSQ,
2462 SSQ, MOMENT, SKEWNESS, KURTOSIS, SEM
2466 # name: <cell-element>
2470 SUMSKIPNAN adds all non-NaN values.
2474 # name: <cell-element>
2481 # name: <cell-element>
2485 TSADEMO demonstrates INVEST1 on EEG data
2489 # name: <cell-element>
2493 TSADEMO demonstrates INVEST1 on EEG data
2498 # name: <cell-element>
2505 # name: <cell-element>
2509 UCP(C) tests if the polynomial C is a Unit-Circle-Polynomial.
2510 It tests if all roots lie inside the unit circle like
2511 B=ucp(C) does the same as
2512 B=all(abs(roots(C))<1) but much faster.
2513 The Algorithm is based on the Jury-Scheme.
2514 C are the elements of the Polynomial
2515 C(1)*X^N + ... + C(N)*X + C(N+1).
2518 O. Foellinger "Lineare Abtastsysteme", Oldenburg Verlag, Muenchen, 1986.
2519 F. Gausch "Systemtechnik", Textbook, University of Technology Graz, 1993.
2523 # name: <cell-element>
2527 UCP(C) tests if the polynomial C is a Unit-Circle-Polynomial.
2531 # name: <cell-element>
2538 # name: <cell-element>
2542 Y2RES evaluates basic statistics of a data series
2545 several statistics are estimated from each column of y
2548 R.N number of samples, NaNs are not counted
2549 R.SUM sum of samples
2551 R.STD standard deviation
2555 ... and many more including:
2556 MEDIAN, Quartiles, Variance, standard error of the mean (SEM),
2557 Coefficient of Variation, Quantization (QUANT), TRIMEAN, SKEWNESS,
2558 KURTOSIS, Root-Mean-Square (RMS), ENTROPY
2563 # name: <cell-element>
2567 Y2RES evaluates basic statistics of a data series