Questions tagged [linearmodels]

A python package which provides estimation and inference in some common linear models including panel data and instrumental variables estimators. For questions related to implementation or interpretation of a linearmodels estimator.

linearmodels is a package which provides some more complex linear estimation techniques to Python, based around numpy and pandas.

Common linear models such as Two-stage least squares, Generalized Method of Moments etc. are missing from the popular statsmodels package and this package fills that gap.

141 questions
25
votes
12 answers

Cast string to float is not supported in Linear Model

I keep getting this error in my linear model: Cast string to float is not supported Specifically, the error is on this line: results = m.evaluate(input_fn=lambda: input_fn(df_test), steps=1) If it helps, here's the stack trace: File…
user3764124
  • 381
  • 1
  • 3
  • 8
10
votes
2 answers

How do I solve the future warning -> % (min_groups, self.n_splits)), Warning) in python?

When I run mean_acc() method in my program, there are % (min_groups, self.n_splits)), Warning) errors... def mean_acc(): models = [ RandomForestClassifier(n_estimators=200, max_depth=3, random_state=0), LinearSVC(), …
School
  • 723
  • 3
  • 8
  • 17
8
votes
2 answers

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,…
LondonRob
  • 73,083
  • 37
  • 144
  • 201
7
votes
1 answer

Using stargazer to output Latex code from linearmodels model fit

I need linearmodels for 2 way clustering, that's not properly implemented in statsmodels. I was wondering if it was possible to use the stargazer python library with the linearmodels package, rather than with statsmodels. But when I plug the model…
LORDER
  • 71
  • 2
7
votes
2 answers

linearmodels panelOLS: Regression output with stars

I'm using the linearmodels package to estimate a Panel-OLS. As an example see: import numpy as np from statsmodels.datasets import grunfeld data = grunfeld.load_pandas().data data.year = data.year.astype(np.int64) # MultiIndex, entity - time data =…
Daniel
  • 304
  • 2
  • 12
6
votes
1 answer

Panel data regression with fixed effects using Python

I have the following panel stored in…
Arturo Sbr
  • 5,567
  • 4
  • 38
  • 76
6
votes
2 answers

Why does Ridge model fitting show warning when power of the denominator in the alpha value is raised to 13 or more?

I was trying to create a loop to find out the variations in the accuracy scores of the train and test sets of Boston housing data set fitted with a Ridge regression model. This was the for loop: for i in range(1,20): Ridge(alpha =…
Vinay Goudar
  • 59
  • 1
  • 1
  • 7
6
votes
1 answer

How to fix the Absorbing Effect Error when trying to include fixed effects in the PanelOLS function in Python's linearmodels?

I am running a fixed effects panel regression use the PanelOLS() function in linearmodels 4.5. While trying to add the 'entity_effects=True' and 'time_effects=True' in the model estimation, it returned 'AbsorbingEffectError': The model cannot be…
G.mc
  • 123
  • 2
  • 10
5
votes
0 answers

Need clarification on the Coef. and St.Err. of random parameter in MixedLM results

I am trying to understand the results of Mixed Linear Models provided by Python statsmodel package. I want to avoid pitfalls in my data analysis and interpretation. The questions are after the data loading/output code block. Loading data and fitting…
3
votes
2 answers

How can I update a linearmodels PanelResults object with custom bootstrap estimates?

I built my own class to implement an estimation procedure (call it EstimationProcedure). To run the procedure, the user calls method fit. First, this fits a Pooled OLS model using the fit method of the PooledOLS class from the linearmodels package.…
Jhonny
  • 568
  • 1
  • 9
  • 26
3
votes
2 answers

Why its takes so much longer to fit model in sklearn.linear_model.QuantileRegressor then R model implementation?

First I used R implementation quantile regression, and after that I used Sklearn implementation with the same quantile (tau) and alpha=0.0 (regularization constant). I am getting the same formulas! I tried many "solvers" and still the running time…
3
votes
2 answers

Pycharm Python Console regression output not aligned

I am relatively new to Python and Pycharm, so I don't know if it is a silly question. Suddenly I got a strange problem: the summary output from any kind of regression in python console is not correctly aligned but, if I run the script from terminal,…
3
votes
2 answers

The index on the time dimension must be either numeric or date-like error

I am trying to do a panel regression with from linearmodels.panel import PooledOLS import statsmodels.api as sm but I encountered a problem with my index. For the regression I need a Multiindex, so I have a Dummy variable and the time (see below).…
CSBossmann
  • 193
  • 2
  • 11
3
votes
2 answers

Polynomial fitting with R using poly vs. I function

I'm trying to understanding polynomial fitting with R. From my research on the internet, there apparently seems to be two methods. Assuming I want to fit a cubic curve ax^3 + bx^2 + cx + d into some dataset, I can either use: lm(dataset, formula = y…
James Ngo
  • 39
  • 2
2
votes
1 answer

Interpreting results from linearmodels PanelOLS .predict() method

Suppose I have the following toy data: import pandas as pd from linearmodels.panel import PanelOLS y = pd.DataFrame( index=[[1, 1, 1, 2, 2, 2], [1, 2, 3, 1, 2, 3]], data=[70, 60, 50, 30, 33, 27], …
Chris
  • 199
  • 9
1
2 3
9 10