# Warning: Rank deficient, rank

Discussion in 'MATLAB' started by Marlene, Jan 3, 2011.

1. ### MarleneGuest

Dear Matlab users,

I am running into a recurrent problem that I would like to understand and, if possible, solve.

I am using the '\' function to estimate 21 model parameters( corresponding to the combination of 2 predictors variables up to the order 5).
I have about 130 experiments (hence 130 {y,x1,x2}) to do this regression.

If I run it up to the 4th order, I model runs smoothly and the obtained model is fairly satisfying.

However, I need a 5th order model (to be coherent with previous work from coworkers).
The model is then quite far off. The first 3 model parameters + another one are given equal to zero and I get the message:Warning: Rank deficient, rank 17 (I guess the 17 corresponds to the 21 parameters I asked for minus the 4 equal to zero)
I don't and won t have additionnal experiments and I really would like to get a 5th order model.
Is there a way to go around?

Thanks a lot

Marlene, Jan 3, 2011

2. ### Greg von WinckelGuest

Can you explain what you are doing in more detail? I assume that you have a some sort of a least-squares Vandermonde system you are trying to solve?

Is your model a polynomial? If so, you can use preexisting data fitting tools such as Matlab's polyfit() function.

If you have your heart set on using a matrix representation, take a look at the singular value decomposition of the matrix with svd() to see what its rank is. It would be unusual to have a 130x5 matrix that is rank deficient. I guess more information is needed.

Greg von Winckel, Jan 3, 2011

3. ### proecsmGuest

proecsm, Jan 3, 2011
4. ### MarleneGuest

Hi again,

My model is indeed polynomial and my code looks like:

%%%%%%%%%%

DesignMat=[ones(Nbpres*Nbtemp,1),PhP,TC,PhP.^2,PhP.*TC,TC.^2,PhP.^3,(PhP.^2).*TC,PhP.*(TC.^2),TC.^3,PhP.^4,(PhP.^3).*TC,(PhP.^2).*(TC.^2),PhP.*(TC.^3),TC.^4,PhP.^5,PhP.^4.*TC,(PhP.^3).*(TC.^2),(PhP.^2).*(TC.^3),PhP.*(TC.^4),TC.^5]

Fit_Params=DesignMat\Exp_values;
%%%%%%%%%%
where:
Dim (Exp_values)=132*1
Dim(DesignMat)=132*21

If I run this code, I get:

Warning: Rank deficient, rank = 17, tol = 6.9333e+002

and
Fit_Params =

0
0
0
0.005289404149152
-0.001747748358411
0
-0.000009531368644
0.000001359824964.........up to 21 parameters

I am not expecting the first 3 parameters to be equal to zero.
Also, althougth the model obtained is not completely off, it is not very satisfying.
When I compare it to the experimental values of pressure it is derived from, I get en error of 60 Hpa.
As a comparison, when I run this same code with a 4th order polynom, I do not get the warning message and the precision of the model is of about 0.02 Hpa.

So it really looks to me like matlab does not handle the regression with that many paramaters.
But again, thoses very same values have been modeled by a 5th order polynom in the past and it would be much easier for me to do just the same.

I hope it makes more sens now..

thanks

Marlene, Jan 4, 2011
5. ### Greg HeathGuest

The second dimension is much larger than 5.
Just the second order model terms take up
6 columns: 1,x1,x2,x1^2,x2^2,x1*x2.

If the matrix is rank deficient the solution
is not unique. Backslash automatically
zeros out some of the terms according to
pivot ratio info. Instead, you can choose
to keep all of the terms by using pinv.

Alternatively, if backslash excluded 4
terms, you can probably choose the alternative
of excluding the 4 fifth order interaction
terms x1^m*x2^n, 1<= m,n <=4, m+n = 5.

Hope this helps.

Greg
..ther terms that exclude the same number of terms
arbitrarily. I would begin by eliminating
the higher order interaction terms

Hope this helps

Greg.

Greg Heath, Jan 4, 2011
6. ### MarleneGuest

Thanks Greg,

I understand better what is going on and, also it would not have been my first choice,
I will stick to a 4th order model.

Your comment about the solution not being unique is very valuable and will probably save me a lot of time when interpreting some of the results.

Thanks a lot

Marlene, Jan 5, 2011