Professional Documents
Culture Documents
Exercise6 RodneyMuganzi
Exercise6 RodneyMuganzi
1
% Plotting the Autocorrelation Function (ACF). This is to check for serial
% correlation in the monthly-averaged DN concentrations
figure;
autocorr(monthly_avg.mean_DN);
title('Autocorrelation Function of Monthly-Averaged DN Concentrations');
TASK 2: De-seasonalize Time Series and TASK 3: Mann-Kendall Test for Trend
2
figure;
autocorr(adjusted_series);
title('Autocorrelation of Adjusted DN Concentrations');
% Perform the Mann-Kendall test on the adjusted series. The main purpose
% for this is to detect significant trends as potrayed in appendix B
[S, KendallTau, pValue] = mannKendallTest(adjusted_series);
S statistic: 13
p-Value: 0.32031
3
% Calculating Sen's Slope
% The purpose here commence the process to compute Sen's slope as outlined
in Appendix C
n = length(adjusted_series); % Determine the number of data points in the
series
slopes = zeros(n*(n-1)/2, 1); % Initializing an array to store the slopes
k = 1; % An index for storing slopes
% Calculating slopes between all pairs of data points, looping over them
for i = 1:n-1
for j = i+1:n
slopes(k) = (adjusted_series(j) - adjusted_series(i)) / (j - i);
k = k + 1;
end
end
4
% Calculate Kendall's tau
KendallTau = S / (n*(n-1)/2);
% Two-tailed p-value
pValue = 2 * (1 - normcdf(abs(Z), 0, 1));
end