OLS regression for bootstrapped data

조회 수: 1 (최근 30일)
Alma Bezares
Alma Bezares 2016년 4월 21일
댓글: Alma Bezares 2016년 4월 22일
Hi, I bootstrapped some data 1000 times and now I want to regress each one of the columns of that bootstrapped data (A) on two vectors. This is: Y= each column in A; X=two vectors, but the "regress" command is not working. Any suggestion? All the data has the same number of rows. Thanks!
  댓글 수: 2
jgg
jgg 2016년 4월 21일
Shouldn't you be repeating the regression command 1000 times? Something like:
for i = 1:1000
Y = A(:,i);
b(i) = regress(Y,X);
end
then do analysis on the 1000 b values reported?
Alma Bezares
Alma Bezares 2016년 4월 22일
Yes, that's exactly what I want to do. Do the regression 1000 times. The problem is that if I use the code that you suggested, it only does the regression on column 1000 and not on the rest of them. If I set Y=(1:i), the command won't work as I'm dealing with a matrix again.

댓글을 달려면 로그인하십시오.

채택된 답변

jgg
jgg 2016년 4월 22일
To answer your question based on my comment. The command Y = A(:,i) selects the i-th column from the A matrix, so this will give you your 1000 results. For instance,
X = randn(5000,2); %fake data; use real data
A = randn(5000,1000); %fake data;
betas = zeros(1000,2);
for i = 1:1000
Y = A(:,i);
betas(i,:) = regress(Y,X);
end
Your estimates are stored in the betas matrix so you can average or consider standard deviation etc.
  댓글 수: 1
Alma Bezares
Alma Bezares 2016년 4월 22일
That seems to work. Thanks a lot!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by