Error using regstats (RESPONSES and DATA must have the same number of rows)
2 views (last 30 days)
Show older comments
Hello!
I must deliver the code for an Econometrics exam and everything is running smoothly except for the following error:
Error using regstats
RESPONSES and DATA must have the same number of rows.
Error in FinancialEconometrics_Homework (line 515)
out=regstats(PInde(:,i),F);
that refers to this part of the code:
out=regstats(PInde(:,i),F);
APToutBtM(i,1:6)=out.beta';
APToutBtM(i,7:12)=out.tstat.t';
APToutBtM(i,13)=out.adjrsquare;
APTresBtM(:,i)=out.r;
I don't know how to solve the problem.
PInde is a 97x25 double matrix and F is a 403x5 double matrix.
Could you please help me?
Thank you
0 Comments
Accepted Answer
Walter Roberson
on 6 Mar 2024
regstats(y,X,model) performs a multilinear regression of the responses in y on the predictors in X. X is an n-by-p matrix of p predictors at each of n observations. y is an n-by-1 vector of observed responses.
So the number of rows of X and y must be the same.
You are using PIndel(:,i) as the y, which will be 97 x 1
You are using F as the X, which will be 403 x 5.
The number of rows of 97 x 1 does not match the number of rows of 403 x 5, so this will fail.
5 Comments
Walter Roberson
on 7 Mar 2024
intercept = ones(size(Me));
intercept = intercept(:,1);
What is the point of that? Why not just
intercept = ones(size(Me,1),1);
More Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!