Effacer les filtres
Effacer les filtres

regress function error for matrix multiplication

1 vue (au cours des 30 derniers jours)
Luca
Luca le 17 Avr 2021
Commenté : Luca le 21 Avr 2021
Hi,
I tried to regress stock returns on market returns and I get this error:
Applying the function '@(x,y){regress(y,x)}' to the 10562nd group of data generated the following error:
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows
in the second matrix. To perform elementwise multiplication, use '.*'.
This is my code.
%% creating variables
A = [ones(size(subset1.MRET)), subset1.MRET];
b = subset1.RET;
%% run regression
[group5, years4, ID3] = findgroups(subset1.years, subset1.ID);
m1 = splitapply(@(x,y) {regress(y,x)}, A, b, group4);
A is a 64121190x2 Matrix
The first column are ones to include the constant and the second column are the Marketreturns.
b is a 64121190x1 Vector
With the stock returns in it.
Does somone know how to deal with this error.
It worked for me, when i used a subset of only 2 stocks.
The dataset is unfortunaltly to big to ubload.
Thank you in advance
  2 commentaires
Shashank Gupta
Shashank Gupta le 20 Avr 2021
For some reason, I am not able to regenerate the error which you are getting, but by the look of it, it seems like some kind of mismatch in input dimension provided to the function. I can further investigate if you can provide me "subset1.Years" and "subset1.ID" may be.
Luca
Luca le 21 Avr 2021
Thank you for your answer. I found the problem there were to many NaN in some years to run the regression.

Connectez-vous pour commenter.

Réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by