% % Written by: % -- % John L. Weatherwax 2009-04-21 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- close all; drawnow; clc; clear; clear functions; % calculate the correlation of these residuals: if( exist('/home/weatherw/Trash/Poularikas/AdaptiveFilteringCode') ) addpath('/home/weatherw/Trash/Poularikas/AdaptiveFilteringCode'); end addpath( '../Chapter3' ); Y_save = load_computer_software_sales(); n = length(Y_save); % downsample our data: n = length(Y_save)-4; Y = Y_save(1:n); Y_test = Y_save( (n+1):end ); fh = figure; plot( Y, 'x-' ); xlabel( 'Time (months)' ); ylabel( 'Monthly Farm Parity Ratios' ); saveas(gcf, '../../WriteUp/Graphics/Chapter5/css_plt', 'epsc' ); fprintf('s^2(Y)= %10.6f, s^2(diff(Y))= %10.6f, s^2(diff(Y,2))= %10.6f, s^2(diff(Y,3))= %10.6f\n',var(Y),var(diff(Y)),var(diff(Y,2)),var(diff(Y,3))) % non-statonary ... take first differences and plot: YD = diff(Y); nd = length(YD); figure; plot( YD, 'x-' ); xlabel( 'Time (months)' ); ylabel( 'Montly Farm Parity Ratios' ); saveas(gcf, '../../WriteUp/Graphics/Chapter5/css_diff_plt', 'epsc' ); r_k = plot_SACF( YD ); title( 'sample autocorrelation function of z_t-z_{t-1}' ); saveas(gcf, '../../WriteUp/Graphics/Chapter5/css_diff_z_t_sacf', 'epsc' ); phi_kk = plot_SPACF( r_k(2:end), nd ); title( 'sample partial autocorrelation function of z_t-z_{t-1}' ); saveas( gcf, '../../WriteUp/Graphics/Chapter5/css_diff_spacf', 'epsc' ); % determine an approporite ARIMA model ... say MA(1) model % calculate the forecasts and 95% prediction intervals for the next 3 months ... done in *.R % calculate the forecast for the combined sales in the next quarter and a 95 % confidence interval ... done in *.R