% % 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_annual_farm_parity_ratios(); fh = figure; plot( Y, 'x-' ); xlabel( 'Time (months)' ); ylabel( 'Monthly Farm Parity Ratios' ); saveas(gcf, '../../WriteUp/Graphics/Chapter5/mfpr_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( 'Time (months)' ); ylabel( 'Montly Farm Parity Ratios' ); saveas(gcf, '../../WriteUp/Graphics/Chapter5/mfpr_diff_plt', 'epsc' ); r_k = plot_SACF( YD ); title( 'sample autocorrelation function of z_t-z_{t-1}' ); saveas(gcf, '../../WriteUp/Graphics/Chapter5/mfpr_diff_z_t_sacf', 'epsc' ); phi_kk = plot_SPACF( r_k(2:end), nd ); saveas( gcf, '../../WriteUp/Graphics/Chapter5/mfpr_diff_spacf', 'epsc' ); % find an approporiate model ... from the autocorrelation and partial autocorrelation plots lets use an ARMA(2,0) model ... see the R script prob_5_24.R % derive predictions for the next four months ... done in the auxillary R function