% % 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; r_k = [ 1, 0.97, 0.94, 0.90, 0.86, 0.81, 0.76, 0.71 ]; n_r_k = length(r_k); n = 100; sf=figure; stem( 0:7, r_k, 'markerfacecolor', 'b' ); axis( [ 0, 7, -0.8, +1.2 ] ); se_r_k = 1.0 / sqrt(n); % plot the value of the standard errors of the sample autocorrelations: figure(sf); hold on; plot( 0:(n_r_k-1), -2*se_r_k*ones(n_r_k,1), 'r-' ); figure(sf); hold on; plot( 0:(n_r_k-1), +2*se_r_k*ones(n_r_k,1), 'r-' ); axis tight; saveas( gcf, '../../WriteUp/Graphics/Chapter5/prob_5_1_z_k_r_k', 'epsc' ); dr_k = [ 1, -0.53, 0.41, -0.35, 0.21, -0.16, 0.15, 0.08 ]; n=100; sf=figure; stem( 0:7, dr_k, 'markerfacecolor', 'b' ); axis( [ 0, 7, -0.8, +1.2 ] ); se_r_k = 1.0 / sqrt(n); % plot the value of the standard errors of the sample autocorrelations: figure(sf); hold on; plot( 0:(n_r_k-1), -2*se_r_k*ones(n_r_k,1), 'r-' ); figure(sf); hold on; plot( 0:(n_r_k-1), +2*se_r_k*ones(n_r_k,1), 'r-' ); axis tight; saveas( gcf, '../../WriteUp/Graphics/Chapter5/prob_5_1_dz_k_r_k', 'epsc' ); % see if the hypothesis of an AR(1) model is supported by looking at the SPACF of ( 1 - B ) z_t : spacf( dr_k(2:end) ) % values are "non-zero" if they are larger than: 2/sqrt(n) % part (b): % r_k_2 = [ 1, -0.42, 0.18, -0.2, 0.07, -0.06, 0.14, 0.05 ]; n=64; sf=figure; stem( 0:7, r_k_2, 'markerfacecolor', 'b' ); axis( [ 0, 7, -0.8, +1.2 ] ); se_r_k = 1.0 / sqrt(n); % plot the value of the standard errors of the sample autocorrelations: figure(sf); hold on; plot( 0:(n_r_k-1), -2*se_r_k*ones(n_r_k,1), 'r-' ); figure(sf); hold on; plot( 0:(n_r_k-1), +2*se_r_k*ones(n_r_k,1), 'r-' ); axis tight; saveas( gcf, '../../WriteUp/Graphics/Chapter5/prob_5_1_z_k_r_k_pt_b', 'epsc' ); % see if the hypothesis of an MA(1) model is supported by looking at the SPACF of z_t : spacf( r_k_2(2:end) ) % values are "non-zero" if they are larger than: 2/sqrt(n)