You are on page 1of 6

1.

SARIMA is utilized to process seasonal data such as following:

2. These seasonal problem can be made into stationary by using log into the equation (Yule
Walker Equation), perform log for all variables
Below are the syntax used in this step. In this case since the seasonal data is NE, we use NE. For any
other variables just substitute the NE.
%% Visually Check The Data
figure(1)
plot(NE)
%% Create Log Variables
lNE=log(NE)
figure(2)
plot(lNE)

As we can see, giving log makes the seasonal data stationary. Then we continue with the syntax.
%% Test NE make it difference on non-seasonals and seasonals
% By looking at the data, difference log is good on 1
% By using log, the variance look homogen now
% Develop code for differencing 1 lag
D1 = LagOp({1 -1},'Lags',[0,1]);
% Develop code for differencing 4 lag
D4 = LagOp({1 -1},'Lags',[0,4]);
% Final differencing for non seasonal = 1, and seasonal = 4
D = D1*D4;
% Starts to filter with non seasonal and seasonal
FlNE = filter(D,lNE);
% Plot the data ready to be analyzed
Figure(3)
plot(FlNE)
%% ACF & PACF
figure(4)
subplot (2,1,1)
autocorr(FlNE)
title('Sample Auto Correlation Function First Difference of Net Export');
subplot(2,1,2)
parcorr(FlNE)
title('Sample Partial Auto Correlation Function First Difference of Net Export');
% Develop model
% Model AR(1)
model1 = arima(1,0,0);
% Model MA(1)
model2 = arima(0,0,1);
% Model ARMA(1,1)
model3 = arima(1,0,1);
% Model MA(1,2)
model4 = arima(1,0,2);
% Model MA(2,1)
model5 = arima(2,0,1);
% Model MA(2,2)
model6 = arima(2,0,2);
% Estimate model
est1_FlNE = estimate(model1,FlNE);
est2_FlNE = estimate(model2,FlNE);
est3_FlNE = estimate(model3,FlNE);
est4_FlNE = estimate(model4,FlNE);
est5_FlNE = estimate(model5,FlNE);
est6_FlNE = estimate(model6,FlNE);
%% Diagnostics and Evaluation for Estimation Net Export Model
res_FlNE = infer(est3_FlNE,FlNE);
disp('Diagnostics and Evaluation for Estimation Net Export Model')
% Autocorrelation
if adftest(res_FlNE)==0
disp('Test 1: The test of residual autocorrelation of the model is failed)')
else
disp('Test 1: The test of residual autocorrelation of the model is success)')
end
% Heteroscedasticity
if archtest(res_FlNE)==1
disp('Test 2: The test of heteroscedasticity of the model is failed)')
else
disp('Test 2: The test of heteroscedasticity of the model is success)')
end
% Normality
if kstest(res_FlNE)==0
disp('Test 3: The test of residual normality is failed)')
else
disp('Test 3: The test of residual normality is success)')
end

3. Afterwards, we plot the result by using this syntax. You can see the estimates for the standardized
residuals as well as the QQPlot.

Below is the syntax used to plot this graph

%% Figure

figure(5);
subplot(2,1,1)
plot(res_FlNE./sqrt(est3_FlNE.Variance))
title('Standardized Residuals for FlNE model estimates')
subplot(2,1,2)
qqplot(res_FlNE)
title('QQPlot Residuals for FlNE model estimates')

4. Next, we check the Y-Hat of the data to compare between the original data and the residual. In this
case we test using GDP and Net Export

The syntax used on this step is:

figure(6);
plot(NE);
hold on;
plot(yNE);
hold off;
title('Y hat NE');
ylabel('in million USD');
xlabel('year');
legend('NE', 'Y hat NE', 'Location','northwest');
grid on;
grid minor;

By this test the closer both line are to overlapping each other, the better the result is.

You might also like