-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathar_tests.m
More file actions
executable file
·60 lines (41 loc) · 1.09 KB
/
ar_tests.m
File metadata and controls
executable file
·60 lines (41 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
clear all
close all
% Play with MATLABs AR toolbox
%% Load the data
pt_oith = '/Users/Orenstein/Desktop/corrected_counts_091817.txt';
[raw, tt] = load_oith(pt_oith, '03-11-2015 12:00:00 PM', '08-01-2015 12:00:00 AM');
%% Generate a bunch of different plots at different lags
smooth = movmean(raw.para, 24);
%%
for ii = linspace(24, 7*24, 7)
x1 = smooth(1:end-(ii-1));
x2 = smooth(ii:end);
figure; plot(x1, x2, '.', 'MarkerSize', 6)
title(sprintf('Lag = %d', ii), 'FontSize', 14)
end
%% Sample autocorrelation sequence out to 50
[xc, lags] = xcorr(smooth, 100, 'coeff');
figure;
stem(lags(101:end), xc(101:end), 'filled')
xlabel('Lag')
ylabel('ACF')
%%
[arcoef, E, K] = aryule(raw.egg, 50);
pacf = -K;
figure;
stem(pacf, 'filled')
xlim([1 50])
uconf = 1.96/sqrt(length(raw.para));
lconf = -uconf;
hold on
plot([1 50], [1 1]'*[lconf uconf], 'r')
grid on
%%
fil = filter(1, arcoef, raw.egg);
figure;
plot(fil)
title('filtered data')
[C, lags] = xcorr(raw.eggs, fil, 1000, 'coeff');
%%
fil = filter(1, arcoef(1:2), raw.egg);
[C, lags] = xcorr(raw.eggs, fil, 1000, 'coeff');