1

I'm using Panel OLS from linearmodels to run the following regression

reg_1 = PooledOLS(y_endog, X_1).fit(cov_type = 'heteroskedastic')

but get an error message saying that the endogenous and exogenous variables aren't the same length.

if y.shape[0] != x.shape[0]:
--> 415             raise ValueError(
    416                 "dependent and exog must have the same number of " "observations."
    417             )

ValueError: dependent and exog must have the same number of observations.

However, if I check the shape of both y_endog and X_1 they are the same shape. I also ensure there are no NaN values by dropping any rows and resetting the index prior to creating the y_endog and X_1 dataframes.

If I run the code where the number of columns in X_1 = 1 the estimation works. However as soon as X_1 has more than 1 column the estimation no longer works (e.g. adding an additional variable to the PooledOLS model).

DataFrames:

y_endog:

y_endog

X_1:

X_1

Nick Parsons
  • 45,728
  • 6
  • 46
  • 64
  • Can you open an issue on the linearmodels tracker? I think you probably should have a multiIndex but this error message isn't helpful. – Kevin S Sep 29 '21 at 12:49

0 Answers0