What's worng with this code
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
% Verify that the Economics Toolbox is installed
if ~license('test', 'Econometrics_Toolbox')
error ('Economics Toolbox is required');
end
% Set Excel file path and sheet name
file_path = 'Korean currency combination.xlsx';
sheet_name = 'Sheet1';
% Importing data from an Excel file
data = xlsread(file_path, sheet_name);
% Setting Variables
E_Price = data(:, 1);
Volume = data(:, 3);
Bond = data(:, 4);
Exchange = data(:, 5);
KOSPI = data(:, 6);
Construction = data(:, 7);
CC2 = data(:, 8);
Vacancy = data(:, 9);
Rent = data(:, 10);
KOFR = data(:, 11);
% Dividend yield (dependent variable) converted from the outside to the next level
DivideYield = data (:, 2); use the second column of Excel file as dividend yield as an example of %
% Configuring an Independent Variable Matrix
X = [E_Price, Volume, Bond, Exchange, KOSPI, Construction, CC2, Vacancy, Rent, KOFR];
% Setting Dependent Variables
Y = DividendYield;
% Create VAR Model
var_model = var(size(X, 2), 1); create a VAR model to match the number of % variables
% Data Settings
data_matrix = [Y, X];
% Estimating VAR Model
var_model = estimate(var_model, data_matrix);
% Output VAR model information
disp(var_model);
Error:
Index at location 2 exceeds array boundaries, index must not exceed 10.
Data seems to be a function and a variable at the same time. If this is not intended, use 'clear data' to remove the variable 'data' from the workspace.
Korean currency combination.xlsx = 한화 합본.xlsx
What's wrong with this codes
2 Kommentare
Walter Roberson
am 1 Feb. 2024
Bearbeitet: Walter Roberson
am 1 Feb. 2024
% Verify that the Economics Toolbox is installed
if ~license('test', 'Econometrics_Toolbox')
error ('Economics Toolbox is required');
end
% Set Excel file path and sheet name
file_path = '한화 합본.xlsx';
sheet_name = 'Sheet1';
% Importing data from an Excel file
data = xlsread(file_path, sheet_name);
% Setting Variables
E_Price = data(:, 1);
Volume = data(:, 3);
Bond = data(:, 4);
Exchange = data(:, 5);
KOSPI = data(:, 6);
Construction = data(:, 7);
CC2 = data(:, 8);
Vacancy = data(:, 9);
Rent = data(:, 10);
KOFR = data(:, 11);
% Dividend yield (dependent variable) converted from the outside to the next level
DividendYield = data (:, 2); %use the second column of Excel file as dividend yield as an example of %
% Configuring an Independent Variable Matrix
X = [E_Price, Volume, Bond, Exchange, KOSPI, Construction, CC2, Vacancy, Rent, KOFR];
% Setting Dependent Variables
Y = DividendYield;
% Create VAR Model
var_model = var(size(X, 2), 1); %create a VAR model to match the number of % variables
% Data Settings
data_matrix = [Y, X];
% Estimating VAR Model
var_model = estimate(var_model, data_matrix);
% Output VAR model information
disp(var_model);
estimate() requires that a model be passed. To create a VAR model you would use something similar to LagOp
Dyuman Joshi
am 1 Feb. 2024
In addition to what Walter has mentioned,
>The variable names don't match -
DivideYield = data(:, 2);
Y = DividendYield;
> The first column is the date-time data, not E_Price. There is a mismatch for other variables as well. And there is no data column named KOFR in the excel file
Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!