Collect OLS regression results

2 views (last 30 days)
Ambrogio
Ambrogio on 18 Mar 2013
Hi guys, I am Ambrogio Dalò, an university student.I am using Matlab for my final dissertation and some commands are still not clear.
What I wont to do with the following script is : 1) Create a dependent variable matrix (SRW) 2) clear my dependt variable form colums with less than n oservation 3) regress the regressor matrix (X) on each dependete variable 4) collect all the results for each j in an cell-arrey matrix
I'll explain my script,in order to be as clear as possible.
for j = 1:245; % start the loop j
SRW = SR(j:j+23,:); % create the dependet variable matrix
A = sum(isfinite(SRW)); % sum the finite value for column
I = find(A<16); % find the colum with less than 16 observatios
SRW(:,I(1:end))=[]; % clear the SRW matrix
S = size(SRW); % find the size of SRW matrix
for i = 1:S(1,2); % start the second loop, whose dimension depend from the size of S
Y = SRW(:,i); % create a dependent variable for each column of SRW
X = horzcat(ones(24,1),Factors(j:j+23,5)); % create the regressors matrix
B = NaN(2,i); % preallocate hte Btas matrix
T = NaN(2,i); % preallocate the t-stat matrix
P = NaN(2,i); % preallocate the P-value matrix
R = NaN(1,i); % preallocate the R^2 vector
[B(:,i),T(:,i),P(:,i),R(:,i)] = NaNOLS(X,Y); % make the regression ignoring the NaN values
All = vertcat(B,T,P,R);
ToT(:,j)={All};
end end
Now, my problem is that the only results available are those for the last i-th regression for j=245.The ohters seem to disappear.I think becouse that for each regression matlab overwrite the results.In this way the only results available are the last one. Is there a way to solve this problem?
Thanks in advance for any help

Answers (0)

Categories

Find more on Matrices and Arrays 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!