regress function error for matrix multiplication
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Shashank Gupta
2021-4-20
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Regression 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!