MULTIPLE LINEAR REGRESSION - 5 Predictors
显示 更早的评论
I wish to perform multiple linear regression of 5 - 6 predictors (X) at a time.
I have total no. of 50 predictors.
I want to find regression coefficients for all possible combinations of predictors from the master dataset of 50 predictors taking 5 and 6 predictors at a time.
Y = a.X1 + b.X2 + c.X3 + d.X4 + e.X5 + f (5 predictors) Y = a.X1 + b.X2 + c.X3 + d.X4 + e.X5 + f.X6 + g (6 predictors)
I also want to find out the correlation coefficient between original Y and predicted Y after multiple Linear Regression.
3 个评论
>> nchoosek(50,5)+nchoosek(50,6)
ans =
18009460
>>
Methinks you needs must rethink your wants...
Whilst it's certainly possible to code a set of loops to do it and maybe one might have sufficient memory to hold the results and perhaps it might even complete in your lifetime simply the sheer number will mean that the likelihood of finding any reason to choose one specific model over another is near zero. You may be able to reject quite a few as being of little value but w/ that many possible combinations the odds are there will be virtually nothing to cause one to select one specific model over another; surely not if you're thinking you're just going to go on blind maximum R-sq.
You'd be far better off to have a physical or other reason to know which are likely predictor variables of interest and pare down the space drastically on that basis.
And, of course, fitting w/o visualization first is always also fraught w/ danger..."beware the nonsense correlation".
Priya
2013-7-23
dpb
2013-7-23
Well, you could try things like ndgrid and/or arrayfun ('uniformoutput','false' will be required) but I'd hold out little hope would save any great amount of time...
If you didn't preallocate for the results, doing that will make a noticeable improvement in the loop construct formulation. I'd not expect the for...end itself here to be the real time problem but simply the amount of "stuff" you're doing in sheer numbers.
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Linear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!