how to search and keep all the possible combinations with a certain accuracy

2 views (last 30 days)
I am trying to do some simple combination, I have a Matrix of X consists of 2000 variables and a Y I want to each time pick 4 of the variables from X and make a regression and keep only those sets that have higher R than 0.9 . I found another solution based on 3 matrices, what want is one matrix and I tried to amend the code but somewhat I did not get it right
tic
X1 = rand(40,2000);
Y = rand(40,1);
in = ones(40,1);
R = zeros(size(:,1),1);
for c = 1:size(:,1)
X = [in X1(:,i)];
yhat = X*(X\Y);
ybar = mean(Y);
ssr = norm(yhat - ybar)^2;
sst = norm(Y - ybar)^2;
R(c) = ssr/sst;
end
toc

Answers (0)

Categories

Find more on Descriptive Statistics in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!