new; cls; library pgraph; #include F:\KangProc.s; T = 246; @ sample period, 1947:II-2008:III @ /*======== loading data ==============*/ load data[T,1] = c:\data\gdpgrowth.txt; @ quarterly GDP growth rate @ tau = 150; @ Great moderation since 1984:IV @ /*======== Step2: Testing =====*/ /*= Step 2-1 : The 1st period =*/ Y1 = data[1:tau]; X1 = ones(tau,1); printr = 0; {bhat1,Yhat1,resid1,sig2hat1,stde1,t_val1,p_val1,F_val1,R21,R21_,SC1,AIC1} = ols1(Y1,X1,printr); /*= Step 2-2 : The 2nd period =*/ Y2 = data[tau+1:T]; X2 = ones(T-tau,1); {bhat2,Yhat2,resid2,sig2hat2,stde2,t_val2,p_val2,F_val2,R22,R22_,SC2,AIC2} = ols1(Y2,X2,printr); F_val = sig2hat1/sig2hat2; @ F statistic @ k = cols(X1); @ # of regressors @ /* Test Results */ "---------------------------------------"; "F-value " F_val; "P-value " cdffc(F_val,tau-k,T-tau-k); "---------------------------------------"; /*======== Step 3: Constructing variance-covariance matrix =====*/ omega = zeros(T,T); Dmat = zeros(tau,1)|ones(T-tau,1); @ Dummy variable @ v = sig2hat1*(1-Dmat) + sig2hat2*Dmat; @ daig(omega) @ omega = diagrv(omega,v); /*======== Step 4: GLS Estimator =====*/ X = X1|X2; @ T by k @ Y = Y1|Y2; @ T by 1 @ b_hat = inv(X'inv(omega)*X)*X'inv(omega)*Y; var_b = inv(X'inv(omega)*X); /*======== Step 5: Results =====*/ "--------------------------------------"; "GLS estimates " b_hat'; "S.E. " sqrt(diag(var_b))'; "--------------------------------------"; end;