# # 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. # #----- r_t = c( 0.39, 0.20, 0.09, 0.04, 0.09, -0.13, -0.05, 0.06, 0.11, 0.02 ) #postscript("../../WriteUp/Graphics/Chapter8/prob_2_ats_plot.eps", onefile=FALSE, horizontal=FALSE) plot( r_t, pch=18 ) abline( h=+1/sqrt(82), col='red' ) # we should really use Bartlett's approximation ... but this should be good enought abline( h=-1/sqrt(82), col='red' ) #dev.off() # Calculate Portmanteau lack of fit test: N = 82 d = 1 n = N - d Q = n * sum( r_t^2 ) K = length(r_t) p = 0 q = 1 dof = K - p - q print(sprintf('Q= %10.6f; 95%% chiSqPt= %10.6f; 99%% chiSqPt= %10.6f',Q,qchisq(0.95,dof),qchisq(0.99,dof)))