Getting different results in different versions of MATLAB

5 次查看(过去 30 天)
I ran this code on 2018b and 2016b versions of MATLAB and got two different results for the T-statistics of AR and MA terms. In 2018 version, I get that most of the terms are statistically insignificant while in 2016 version, all the terms are statistically significant. What might be the reason behind such huge difference in result in two different versions?
clc;
clear;
data= xlsread('oil_gas.xlsx');
P=data(7:end,2); %Gas price
Y = log(P);
N = length(Y); % no.of observations
dY=diff(Y); %convert the price series into a stationary time series
% Step 1. Plot the variables and test for unit root
figure(1);subplot(2,1,1),plot(Y),...
title('Log Gas Price 1/21/1991-5/13/2011');
figure(1);subplot(2,1,2),plot(dY),...
title('Log Difference of Gas Price 1/21/1991-5/13/2011');
% Next Test for a unit root against a stationary alternative,
h_Y = adftest(Y,'lags',0:10) %augmenting the model with 0 to 11 lagged difference terms.
% The values h = 0 indicate that all tests fail to reject the null hypothesis of a unit root against the stationary alternative.
h_dY = adftest(dY,'lags',0:10)
%The values h = 1 indicate that all tests reject the null hypothesis of unit root, indicating a stationary process for the difference
% Step 2. Plot the sample ACF and PACF.
%Plot the sample autocorrelation function (ACF) and partial autocorrelation function (PACF) for Y and dY.
figure (2)
subplot(2,2,1)
autocorr(Y)
subplot(2,2,2)
parcorr(Y)
subplot(2,2,3)
autocorr(dY)
subplot(2,2,4)
parcorr(dY)
%Step 3. Specify and fit an ARIMA model.
model1=arima('ARLags', [5,10, 15,20,25], 'MALags',[5,10,15,20], 'D', 0, 'Constant', 0, 'Distribution', 'Gaussian');
model2=arima('ARLags', [5,10, 15,20,25], 'MALags',[5,10,15], 'D', 0, 'Constant', 0, 'Distribution', 'Gaussian');
%model2=arima('ARLags', [5,10, 15,20,25], 'MALags',[5,10,15,20,20], 'D', 0, 'Constant', 0, 'Distribution', 't');
%Note: using t distribution gives a df of 2, which implies infinite variance, as a result, the estimation is not valid. so we do not use t distribution.
%The augmented dicky fuller tests indicate unit root of Y, but stationary of the first difference of Y:dy. Therefore set the integration term to D=1
NEW_Y=dY(1:N-30);
T=length(NEW_Y);
[est1, estcov1,logl1] = estimate(model1,NEW_Y);
numParams1=length(estcov1)-1
[AIC1,BIC1] = aicbic(logl1, numParams1,T)
[est2, estcov2,logl2] = estimate(model2,NEW_Y);
numParams2=length(estcov2)-1
[AIC2,BIC2] = aicbic(logl2, numParams2,T)
%Step 4. Check goodness of fit.
%Infer the residuals from the fitted model. Check that the residuals are normally distributed and uncorrelated.
res1 = infer(est1,NEW_Y);
res2 = infer(est2,NEW_Y);
figure (3)
subplot(2,2,1)
plot(res1./sqrt(est1.Variance))
title('Standardized Residuals')
subplot(2,2,2)
qqplot(res1)
subplot(2,2,3)
autocorr(res1)
subplot(2,2,4)
parcorr(res1)
%figure (4)
%subplot(2,2,1)
%plot(res2./sqrt(est2.Variance))
%title('Standardized Residuals')
%subplot(2,2,2)
%qqplot(res2)
%subplot(2,2,3)
%autocorr(res2)
%subplot(2,2,4)
%parcorr(res2)
%Step 5. Generate forecasts.
%Generate forecasts and approximate 95% forecast intervals for the next 30 days.
[Yf,YMSE] = forecast(est1,30,'Y0',NEW_Y);
UB = Yf + 1.96*sqrt(YMSE);
LB = Yf - 1.96*sqrt(YMSE);
figure (5)
h1 = plot(dY,'Color',[.75,.75,.75]);
hold on
h2 = plot((5265:5294),Yf,'r','LineWidth',2);
h3 = plot((5265:5294),UB,'k--','LineWidth',1.5);
plot((5265:5294),LB,'k--','LineWidth',1.5);
%datetick('x','yy');
%set(gca,'XTick',1:10:N);
%set(gca,'XTickLabel',datestr(date(1:0:N),17));
legend([h1,h2,h3],'Log gas price','Forecast',...
'Forecast Interval','Location','Northwest')
title('Log Gas Price Forecast')
  1 个评论
Daniel Sadono
Daniel Sadono 2021-8-16
Hi, have you found the solution? Perhaps you can also share some information. I'm experiencing the same condition, that I have same model, run on different matlab 2016b and 2018b, and using the same laptop. However, I found also a similar problem as Different svd results with R2015b and R2016a - MATLAB Answers - MATLAB Central (mathworks.com). Perhaps the answer from that staff
( Both results are correct up to machine precision. The reason for the difference between MATLAB versions is that the MKL library (containing the BLAS and LAPACK libraries which are used for the linear algebra computations) has been updated between releases.
To check the version of the MKL used in MATLAB, type
>> version -blas
The reason that the results changed is likely due to a difference in the order of operations. This will affect the results in small ways, without there necessarily being a better or worse result. Such small changes are likely to happen between any two MATLAB versions, as the MKL version is updated regularly.) might clear you out.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Polynomials 的更多信息

标签

产品


版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by