Whats wrong in this code? About error code:zeros
2 次查看(过去 30 天)
显示 更早的评论
% 예시: 그레인저 인과 검정을 위한 코드
% 시계열 데이터가 있는 엑셀 파일 불러오기
data = readtable("Data1.xlsx");
% 'Date' 열을 datetime 형식으로 변환
data.Date = datetime(data.Date, 'InputFormat', 'yyyy-MM-dd');
% 시계열 데이터 선택 (예시로 여러 변수 사용)
selected_data = data(:, {'Date', 'Price' 'E_Price' 'H_Price' 'L_Price' 'Previous_f' 'Volume'});
% VAR 모델 구축
var_order = 2; % VAR 모델의 차수
data_matrix = table2array(selected_data(:, 2:end));
% 데이터를 행렬 형태로 변환하여 VAR 모델 피팅
num_responses = size(data_matrix, 1);
var_model = varm(num_responses, var_order);
var_fit = estimate(var_model, data_matrix');
% 그레인저 인과 검정 수행
lag_order = 1; % 그레인저 인과 검정의 시차
granger_test_result = grangercausalitytest(data_matrix, lag_order, 'NumLags', var_order);
% 결과 출력
disp('Granger Causality Test Results:');
disp(granger_test_result);
2 个评论
Walter Roberson
2024-1-29
grangercausalitytest() is not part of MATLAB.
I looked around the File Exchange but could not find grangercausalitytest()
Dyuman Joshi
2024-1-29
编辑:Dyuman Joshi
2024-1-29
Please share the data file "Data1.xlsx" and any user defined functions used, so that we can run your code, reproduce the error and provide suggestions/solutions. Use the paperclip button to attach.
Also, please share the complete error message you get (i.e. all of the red text).
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!