LondonRob
LondonRob

Reputation: 78923

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?

Upvotes: 9

Views: 8312

Answers (2)

Peter
Peter

Reputation: 1076

(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).

Upvotes: 4

Shivank Goel
Shivank Goel

Reputation: 31

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.

Upvotes: 3

Related Questions