Errors about VAR modeling

4 visualizzazioni (ultimi 30 giorni)
형현
형현 il 2 Feb 2024
Modificato: Akash il 14 Feb 2024
% 외부 엑셀 데이터 불러오기
file_path = '한화 합본.xlsx'; % 실제 데이터 파일의 경로를 입력해야 합니다.
sheet_name = 'Sheet1';
% 엑셀 파일에서 데이터 가져오기
data = readtable(file_path, 'Sheet', sheet_name);
% 필요한 변수 선택
variables = {'E_Price', 'ror', 'Volume', 'Bond', 'CC2', 'Construction', 'Exchange', 'KOSPI', 'Vacancy', 'Rent'};
% 최대 시차 설정
max_lag = 7;
% 표 초기화
result_table = table((1:max_lag)', zeros(max_lag, 1), zeros(max_lag, 1), zeros(max_lag, 1), zeros(max_lag, 1), zeros(max_lag, 1), 'VariableNames', {'Lag', 'LR', 'FPE', 'AIC', 'SC', 'HQ'});
% 각 시차에 대한 판단 기준 계산 및 출력
for lag = 1:max_lag
% VAR 모델 적합
var_order = lag; % 시차
var_model = varm(length(variables), var_order);
est_model = estimate(var_model, data{:, variables});
% Likelihood Ratio Test (LR)
[~, ~, lr_stat, ~] = lratiotest(est_model);
% Final Prediction Error (FPE)
fpe_criterion = fpe(est_model);
% Akaike Information Criterion (AIC)
aic_criterion = aic(est_model);
% Schwarz Bayesian Criterion (SC or BIC)
bic_criterion = bic(est_model);
% Hannan-Quinn Criterion (HQ)
hq_criterion = hqcriter(est_model);
% 결과 테이블에 값 저장
result_table{lag, 2:6} = [lr_stat, fpe_criterion, aic_criterion, bic_criterion, hq_criterion];
end
Warning: Rank deficient, rank = 78, tol = 2.815407e-01.
Warning: Rank deficient, rank = 79, tol = 2.825122e-01.
Warning: Rank deficient, rank = 79, tol = 2.833563e-01.
Warning: Rank deficient, rank = 79, tol = 2.863520e-01.
Warning: Rank deficient, rank = 79, tol = 2.868077e-01.
Warning: Rank deficient, rank = 79, tol = 2.868242e-01.
Warning: Rank deficient, rank = 79, tol = 2.868247e-01.
Warning: Rank deficient, rank = 79, tol = 2.868247e-01.
Warning: Rank deficient, rank = 79, tol = 2.868247e-01.
Warning: Rank deficient, rank = 79, tol = 2.868247e-01.
Warning: Rank deficient, rank = 79, tol = 2.868247e-01.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 3.573747e-21.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 5.941222e-42.
Error using lratiotest
At least three inputs must be specified.
% 결과 테이블 출력
disp(result_table);
There are too many errors. Through the adf test, I try to analyze the appropriate parallax of Var with 7 levels of parallax for a total of 5 criteria with the time series data file that completed the unit root test by performing the 1st and 2nd differences of each angle, but I keep getting these errors. Please solve it.

Risposte (1)

Akash
Akash il 14 Feb 2024
Modificato: Akash il 14 Feb 2024
Hi 형현,
The error with "lratiotest" indicates that the function requires at least three input arguments. These arguments are the loglikelihood maxima for both the unrestricted and restricted models, the degrees of freedom, and an optional argument for nominal significance levels. The error suggests that not all necessary inputs were provided. For more detailed information on the required input arguments and their specifications, you can refer to the below provided MATLAB documentation for "lratiotest":-https://www.mathworks.com/help/econ/lratiotest.html#:~:text=for%20the%20test.-,Input%20Arguments,-collapse%20all
The warnings regarding 'rank deficiency' indicate that the matrix involved in the estimation process is not of full rank. This condition often arises when there are linear dependencies among the rows or columns of the matrix, which can lead to inaccurate results. To address this, you can examine the data for multicollinearity using the "corrcoef" function, which returns the correlation coefficients between variables. For more information, you can utilize the below provided MATLAB documentation for "corrcoef". This can help identify linear dependencies in your data. More observations can also improve the rank of the matrix, so if it is feasible, you can consider expanding your dataset.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by