% % 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; clear functions; rehash; clc; if( exist('/home/weatherw/Trash/Poularikas/AdaptiveFilteringCode') ) addpath('/home/weatherw/Trash/Poularikas/AdaptiveFilteringCode'); end addpath( '../Chapter2/' ); addpath( '../Chapter4/' ); % plot_SACF.m Y = load_master_card_applications(); fh = figure; plot( Y, 'x-' ); xlabel( 'Month starting from Januwary 1967' ); ylabel( 'MC applications' ); saveas(gcf, '../../WriteUp/Graphics/Chapter5/mca_plt', 'epsc' ); % stabalize the variance with a logorithmic transform: Y = log(Y); fh = figure; plot( Y, 'x-' ); xlabel( 'Month starting from Januwary 1967' ); ylabel( 'Log MC applications' ); saveas(gcf, '../../WriteUp/Graphics/Chapter5/log_mca_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); figure; plot( YD, 'x-' ); xlabel( 'Month starting from Januwary 1967' ); ylabel( 'MC applications' ); saveas(gcf, '../../WriteUp/Graphics/Chapter5/mca_diff_plt', 'epsc' ); r_k = plot_SACF( YD ); title( 'sample autocorrelation function of z_t-z_{t-1}' ); saveas(gcf, '../../WriteUp/Graphics/Chapter5/mca_diff_z_t_sacf', 'epsc' ); phi_kk = plot_SPACF( r_k(2:end), nd ); saveas( gcf, '../../WriteUp/Graphics/Chapter5/mca_diff_spacf', 'epsc' ); % find an approporiate model ... use an MA(1) model ... see the R script prob_5_24.R theta = 0.6666; sigma = sqrt(0.04553); % derive predictions for the next four months ... done in the associated *.R file