Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ValueError: exog does not have full column rank

I'm running a PanelOLS from the linearmodels package.

As must very often be the case, some observations are missing. When I run the equivalent command in R (I think the equivalent command is plm) I get the following:

Unbalanced Panel: n=11, T=17-61, N=531

So the panel is unbalanced: some of the individuals only have complete data for 17 time periods and others for many more. But the regression runs nevertheless.

The equivalent python command is:

import linearmodels.panel as pnl
model = pnl.PanelOLS.from_formula(formula, data=src)

Which gets me a warning:

Inputs contain missing values. Dropping rows with missing observations.

and also an error:

MyPythonInstallation\lib\site-packages\linearmodels\panel\model.py in _validate_data(self)
    207 
    208         if matrix_rank(x) < x.shape[1]:
--> 209             raise ValueError('exog does not have full column rank.')
    210         self._constant, self._constant_index = has_constant(x)
    211 

ValueError: exog does not have full column rank.

How can I proceed with my regression?

like image 564
LondonRob Avatar asked Oct 16 '17 16:10

LondonRob


2 Answers

I had the same error. In my case, one of the columns of the data-frame which I was using was being considered as an 'object' datatype. Changing that column to the 'float' data type solved the problem for me.

like image 112
Shivank Goel Avatar answered Oct 14 '22 21:10

Shivank Goel


(I realize the OP is not working on this anymore, but just in case someone else needs it...)

Another possible reason that bites me in the behind when I am being sloppy (sorry, I meant quick and efficient) -- check if you've included variables that are a linear combination of the others (e.g. both lags and diffs).

like image 44
Peter Avatar answered Oct 14 '22 23:10

Peter