Why does gctest fail when using discontinuous lags?
조회 수: 1 (최근 30일)
이전 댓글 표시
I'm running a Granger-causality test on a varm model object. The gctest function returns an indexing error when the lags are discontinuous. For example it works when lags = 1,2,3,4. It fails when lags = 1,2,4. Below code recreates the error.
%Following Matlab gctest example
load Data_USEconModel
m1slrate = price2ret(DataTable.M1SL);
inflation = price2ret(DataTable.CPIAUCSL);
rgdprate = price2ret(DataTable.GDP./DataTable.GDPDEF);
tbl = table(m1slrate,inflation,rgdprate);
tbl = rmmissing(tbl);
T = size(tbl,1); % Total sample size
numseries = 3;
% Partition time base.
maxp = 4; % Maximum number of required presample responses
idxpre = 1:maxp;
idxest = (maxp + 1):T;
% Fit VAR models to data.
Y0 = tbl{idxpre,:}; % Presample
Y = tbl{idxest,:}; % Estimation sample
%Two different models. Second model omits lag number 3
lags1=[1:4];
lags2=[1,2,4];
coef0=nan(numseries,numseries);
numlags1=length(lags1);
numlags2=length(lags2);
for i=1:length(lags1)
coef_1{i}=coef0;
end
for i=1:length(lags2)
coef_2{i}=coef0;
end
Mdl_1 = varm('AR',coef_1,'Lags',lags1);
EstMdl_1 = estimate(Mdl_1,Y,'Y0',Y0);
gctest(EstMdl_1)
Mdl_2 = varm('AR',coef_2,'Lags',lags2);
EstMdl_2 = estimate(Mdl_2,Y,'Y0',Y0);
gctest(EstMdl_2) %gctest fails for the second model
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Vector Autoregression Models에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!