How to do autocorrelation with a given data
Show older comments
Hi, Could you help me please? I have data (t,A). t stands for time, A for Absorbance, and i have it in txt file. I'd like to analyze it with autocorrelation function. I tried writing the code, I did just like how i understand what i read the mathworks site 'Autocorr'. But simply saying, i'm afraid the data 't' that i have is not included in the process with my coding. Could I get more explanation, or a validation maybe? thank you.
just for example the data is
t = 3:3:30
A = 3.523;3.523;3.43;3.323;3.43;3.43;3.323;2.923;2.723;2.923;
[t,A]=textread('Data.txt')
[acf,lags]=autocorr(A)
Accepted Answer
More Answers (1)
I don't have the Econometric Toolbox so I can't use autocorr but I can use the regular xcorr. Maybe this will help you:
t = 3:3:30;
A = [3.523;3.523;3.43;3.323;3.43;3.43;3.323;2.923;2.723;2.923];
subplot(2, 1, 1);
plot(t, A, 'b-', 'LineWidth', 2);
grid on;
xlabel('t');
ylabel('A')
title('Original Data')
% [t,A]=textread('Data.txt')
% [acf,lags]=autocorr(A)
autoCorrA = xcorr(A);
subplot(2, 1, 2);
plot(autoCorrA, 'b-', 'LineWidth', 2);
grid on;
xlabel('Index');
ylabel('Autocorrelation Value')
title('Autocorrelation Signal')
2 Comments
Sasha
on 28 Oct 2024
Image Analyst
on 28 Oct 2024
I'm not really familiar with the autocorrelation function. It seems different than the usual one we all know. They say
"
The autocorrelation function measures the correlation between the univariate time series yt and yt + k, where k = 0,...,K and yt is a stochastic process.
rk=ckc0,
where
- ck=1TT−k∑t=1(yt−‾y)(yt+k−‾y).
- c0 is the sample variance of the time series.
Suppose that q is the lag beyond which the theoretical ACF is effectively 0. Then, the estimated standard error of the autocorrelation at lag k > q is
SE(rk)=⎹⎷1T(1+2q∑j=1r2j).
If the series is completely random, then the standard error reduces to 1/√T.
"
You probably know more about that function than me. Sorry but I don't really know when you'd use that. I'm guessing it's something special for econometrics applications.
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

