Easy question for an economist

Is there a way to compute multiple linear regression (the script already is working fine) but i need to be able to say something like : for all combinations of X's do a LinearModel.fit with Y (It's working at this point) AND after switch to another Y ( I have 70 Y to test). Can I do something like :
%
for i = 1:15
for j = 1:15
REG = LinearModel.fit({DS{1,i},Y{1,j})
RSQ{1,i}(1,1) = REG.Rsquared.Adjusted
COEFF{1,i} = REG.Coefficients
end
end

回答 (2 件)

Shashank Prasanna
Shashank Prasanna 2013 年 6 月 10 日

0 投票

You can certainly fit a linear model in a loop for different response values in Y for the same predictors. But I am guessing there is a step after this.
Could you elaborate on the what you are trying to do, because there may be other tools. For example, mvregress can be used when you actually have a multivariate response Y.

3 件のコメント

Simon
Simon 2013 年 6 月 10 日
編集済み: Simon 2013 年 6 月 10 日
I have 50 predictors and i made every combination of 4 predictors (with nchoosek (230600 combo in 'E' matrix) and every predictor is in a proper dataset). I was wondering if I could make a matrix 1xn with all Y inside, then with every Y{1,n} test it with all combination (230600). I thought maybe with
% for i = 1:230600
Z = nchoosek({E, Y{1,i}},2)
end
Shashank Prasanna
Shashank Prasanna 2013 年 6 月 11 日
You can certainly try, but is the end goal just to collect all the coefficients and residuals? If your question is: can I try combinations, you certainly can, but I was trying to see if there is a bigger problem you are trying to solve here.
If something is not working or you are getting stuck, please provide more info, err msg etc.
Simon
Simon 2013 年 6 月 11 日
The final goal is to gather the best coeffs (of all predictor combinations) of every Y. Thank you i will try it and post err msg if any.
Simon
Simon 2013 年 6 月 11 日

0 投票

Bump

この質問は閉じられています。

質問済み:

2013 年 6 月 10 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by