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
1
vote
0 answers

How to account for both spatial and temporal autocorrelation at the same in lme?

I would like to know how to account for both spatila and temporal autocorrelation at the same time using autoregressive models by lme() function. To account for the spatial autocorrelation, I use corSpher model_temp<-lme(Y~X1+Year, …
1
vote
1 answer

How to get the interceipt from model summary in Python linearmodels?

I am running a panel reggression using Python linearmodels, something like: import pandas as pd from linearmodels.panel import PanelOLS data = pd.read_csv('data.csv', sep=',') data = data.set_index(['panel_id', 'date']) controls =…
izhako
  • 133
  • 1
  • 1
  • 9
1
vote
1 answer

Wald test with panel ols in python

I am trying to test hypothesis that all intercepts coefficients in pooled OLS are equal to zero with: F-test, Likelihood Ratio and Wald-test. I have some problems with the last one. Here is the code PanelOLS((table1['Return']-table1['RF']),…
1
vote
1 answer

Python Linearmodels: How to let Python know these are ID columns to identify Group?

I would like to run a panel regression (fixed-effect model) on a group of individuals, which are uniquely identified by province and city, across time t. Code to create dataframe and run the regression import numpy as np import pandas as pd from…
June
  • 335
  • 4
  • 15
1
vote
1 answer

Regression standard error clustering AND robust to heteroskedascity + serial autocorrelation

As indicated in the title, I'm trying to run a regression in python where the standard errors are clustered as well as robust to heteroskedascity and autocorrelation (HAC). I'm working within statsmodels (sm), but obviously open to using other…
1
vote
1 answer

What is F-Test for Poolability in the Fixed Effect Model?

I am currently running regressions with Panel data, and was wondering which Panel Regression model is the best. I ran the PooledOLS and Fixed Effect Model using the Panel OLS (with entity effect and time effect being true). I am trying to understand…
1
vote
0 answers

sklearn LinearModel, Ridge and Lasso produce incompatible output?

I am playing a bit with differnt regression models on the boston house dataset. I found that if I use a normal linear model or ridge regression the predicted values are of shape (102, 1) while if I use the identical code with Lasso the output is…
lordy
  • 610
  • 15
  • 30
1
vote
1 answer

3d Surface plot from linear model with matplotlib in Python

The following code was working fine. But now it is throwing the following error: AttributeError: 'Series' object has no attribute 'reshape' Code: from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np import…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
1
vote
1 answer

JAGS multiple linear regression with y[i] GAMMA (bayesian)

I have a question about this model in JAGS, I want to make a bayesian linear regression with a y[i] that follows not a normal distribution but a gamma. The model is this: "model { Priors: a ~ dnorm(0, 0.0001) # mean, precision = N(0, 10^4) b ~…
1
vote
1 answer

How do you exclude interaction term in r lm?

I'm working with a model from the Prestige dataset in the car package in R. library(car) library(carData) data = na.omit(Prestige) prestige = data$prestige income = data$income education = data$education type = data$type I'm trying to fit the…
jjt3
  • 91
  • 1
  • 4
1
vote
0 answers

Creating new data frame with dplyr::filter within a for loop

I have a dataset that I would like to fit a bi-linear model to. However, I would also like some justification for finding the transition point. I wanted to loop through possible values for the transition point, separate the data using…
d73mwf
  • 11
  • 1
  • 4
1
vote
1 answer

Setting dependent variable via numeric indexing in linear model in R

I'm trying to set the name of a column (or a specific vector element) as my dependent variable (DV) in a linear model in R. When I do this manually by typing "ITEM26", there are no errors. The DV (y) is ITEM26, and the predictors are every other…
iambwoo
  • 15
  • 4
1
vote
1 answer

Fixed effects model using Python linearmodels

I am a little confused by the requirement for a MultiIndex using linearmodels PanelOLS. I'm trying to create a model of the form y = pid(i) + rid(j) + e(ij) where e is the error term. My data essentially looks like this: Dataframe image In this case…
Daniel
  • 31
  • 2
  • 4
1
vote
2 answers

How to create a table in R

I created a for-loop to form a linear model with features and remove one feature every one cycle of the for-loop. Using this for loop, I want to take-out pvalues of each features. Below is my fake data and the for loop: #fake data z <- c(0.91629, …
Yun Tae Hwang
  • 1,249
  • 3
  • 18
  • 30
1
vote
0 answers

Linearmodels value error - do not have full column rank

This is similar to another question. I'm running a 2-stage least square regression with set of categorical variables. I've run the model successfully once but when I tried to replicate the model it ran into this error: ValueError: instruments…
R_Queery
  • 497
  • 1
  • 9
  • 19