%% This modification is for the case when we first fit a trend %% --here, quadratic, %% and then fit the seasonal. We also attempt to find autocorrelation X = load('./data/mauna-loa.csv'); co2 = X(:,2); co2 = co2(11:length(co2)); % throw out first 10 months n = length(co2); % number of obs years = 50; M = 6; w = ones(2*M+1,1)/12; w(1) = 1/24; w(13) = 1/24; m = co2*0 + 300; for t = (M + 1):(n-M), m(t) = sum( co2((t-M):(t+M)).*w); end plot(co2) hold on plot(m,'r');