Recursive time-series regression and storing results (HAVING TROUBLE WITH RESIDUALS)

1 view (last 30 days)
Hello community!
I write to you because I am having trouble with a piece of code for my master thesis.
I am trying to recursively regress two 200x273 matrices (regress column 1 of A on column 1 of B, column 2 of A on column 2 of B and so on....)
I am especially having trouble extracting the residuals of each observation in each regression: concretely, as output I would like:
A vector 273x1 of Betas (estimates)
A vector 273x1 of Alphas (constants)
A matrix 200x273 of residuals
A table of descriptive stats (r^2, p-values etc.) for each of the 273 regressions
This is the code as I have it now:
for i = 1:size(volatility_TEST_e, 2)
for k = 1:size(volatility_TEST_e, 1) Not sure about this
% Get the ith column of volume
Y = vol_firms_time_frame_TEST_e(:,i);
% Get the ith column of volatility
X = [ones(200,1), volatility_TEST_e(:,i)];
[b,r] = regress(Y,X);
Output_Alpha(i,:)=b(1,:)
Output_Beta(i,:)=b(2:end,:);
Output_Residual(i,k)=r(1:end,k); This doesn't work
end
end
I have successfully accomplished outputs 1 and 2, but need help for 3 and 4.
Cheers!
Giorgio

Answers (0)

Categories

Find more on Descriptive Statistics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!