How can I use 'regstats' to make a multiple linear regression with more than three predictor variables?

조회 수: 3 (최근 30일)
I am currently using the following code:
predictors = [Hs2 Dp2 Tp2 windvelocity windirection] % 12x5
Y = [LCvelocity] % 12x1
qualstat = {'rsquare'};
rsquare05 = regstats([LCvelocity],[predictors],...
'quadratic', qualstat);
r2=[rsquare05.rsquare]';
r=sqrt(r2)
Error using regstats (line 124)
The design matrix has more predictor variables than observations.
But the error keeps happening, unless I diminish the predictors matrix to a 12x3 size, in this case my code works. Anyone knows what is the problem?
  댓글 수: 2
dpb
dpb 2019년 5월 28일
Editing the comment to match the number of predictor variables doesn't solve the basic problem of trying to fit a 20-coefficient model with only 12 data points.
It's simply impossible.
G.Bose
G.Bose 2019년 5월 28일
I got it! I just eddited because I really didn't realize I miscounted. Thanks.

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

채택된 답변

dpb
dpb 2019년 5월 28일
편집: dpb 2019년 5월 29일
You've asked for a full quadratic model in 5 (not 4) predictor variables. That's a total of 5 quadratic + 5 linear + 9 (4+3+2) interaction terms + 1 constant term --> 20 coefficients to estimate with only 12 observations.
ERRATUM
Actually, there are 21 coefficients, not 20...I knew something seemed peculiar but didn't catch it at the time.
...+ 10 (4+3+2+1) interaction terms ...
I left off the last cross term...now back to our regularly scheduled programming...dpb
With three predictors it's "only" 3+3+3+1 = 10 which is still way overfitting the data with only 2 DOF left but at least is computable.
ADDENDUM
You could start with a simple linear model of the five predictors and see what happens...of course, model fitting without first plotting to see what the data look like is like playing darts blindfolded.
And, with only 12 data points in 5-vector space, it's going to be very difficult to do very much, anyway; you just don't have enough points to cover the dimensionality.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Model Building and Assessment에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by