1 function [PARCOR,sig,cil,ciu]= pacf(Z,KMAX);
2 % Partial Autocorrelation function
3 % [parcor,sig,cil,ciu] = pacf(Z,N);
6 % Z Signal, each row is analysed
10 % parcor autocorrelation function
11 % sig p-value for significance test
12 % cil lower confidence interval
13 % ciu upper confidence interval
15 % see also: DURLEV, LATTICE, AC2RC, AR2RC,
16 % FLAG_IMPLICIT_SIGNIFICANCE
18 % $Id: pacf.m 5090 2008-06-05 08:12:04Z schloegl $
19 % Copyright (C) 1997-2002,2008 by Alois Schloegl <a.schloegl@ieee.org>
21 % This program is free software: you can redistribute it and/or modify
22 % it under the terms of the GNU General Public License as published by
23 % the Free Software Foundation, either version 3 of the License, or
24 % (at your option) any later version.
26 % This program is distributed in the hope that it will be useful,
27 % but WITHOUT ANY WARRANTY; without even the implied warranty of
28 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 % GNU General Public License for more details.
31 % You should have received a copy of the GNU General Public License
32 % along with this program. If not, see <http://www.gnu.org/licenses/>.
36 warning('too less elements.\nmake sure the data is row order\n')
38 [s,n] = sumskipnan(Z,2);
39 Z = Z - repmat(s./n,1,nc); % remove mean
41 if (nargin == 1), KMAX = N-1; end;
43 AutoCov = acovf(Z,KMAX);
44 [AR,PARCOR,PE] = durlev(AutoCov); % PARCOR are the reflection coefficients
45 %[AR,PARCOR,PE] = lattice(Z,KMAX); % PARCOR are the reflection coefficients
46 PARCOR = -PARCOR; % the partial correlation coefficients are the negative reflection coefficient.
48 if nargout<2, return, end;
52 s = 1./sqrt(repmat(n,1,KMAX)-1-ones(nr,1)*(1:KMAX));
53 sig = normcdf(PARCOR,0,s);
57 if nargout<3, return, end;
58 % calculate confidence interval
59 if exist('flag_implicit_significance')==2;
60 alpha = flag_implicit_significance;
65 fprintf(1,'PACF: confidence interval for alpha=%f\n', alpha);
66 ciu = norminv(alpha/2).*s;