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
0
votes
1 answer

linearmodels or statsmodels - what are the main differences?

Can anyone explain the different between statsmodels and linearmodels. They are both very similar with respect to many things, but I assume they must also differ? Does anyone have any insights to share?
Chris
  • 433
  • 4
  • 17
0
votes
1 answer

Can't load datasets from linearmodel python package

I am trying to learn the linearmodels package for python. I want to do this by practicing with the data sets, as can be seen here. Example code: import numpy as np from linearmodels.iv import IV2SLS from linearmodels.datasets import mroz data =…
J.A.Cado
  • 715
  • 5
  • 13
  • 24
0
votes
0 answers

Linearmodels FamaMacBeth 'list' argument must have no negative elements

I'm trying to run some Fama MacBeth regressions using the FamaMacBeth functionality from linearmodels (version 4.8) and I'm running into the following error: ValueError Traceback (most recent call last) …
matthijs
  • 1
  • 1
  • 2
0
votes
0 answers

Function to determine if f statistic is significant

Is there a function in R to calculate the critical value of F-statistic and compare it to the F-statistic to determine if it is significant or not? I have to calculate thousands of linear models and at the end create a dataframe with the r squared…
Jenny Wang
  • 25
  • 3
0
votes
0 answers

Why does predict function give out NA in its response?

I prepared a model with R's inbuilt glm. After the model was created, I passed the model and testData to predict function. The code is as follows: data = read.csv(file = "twitter-dataset.csv") testData = read.csv(file =…
Lambar
  • 51
  • 6
0
votes
0 answers

Use MLPRegressor to get better results as linear model

My Problem is to get better result in MSE and i hope in R2 as in linear model. So i used the sklearn.neural_network.MLPRegressor library to compare it def testfit(v,k,subset=2,hls=(50,50,50,10),acv='identity'): # prep variables n = len(v) n1 =…
Moritz
  • 47
  • 6
0
votes
0 answers

Leads/Lags in linear model with a subsample of the data frame in R

I want to perform in R the next linear model: \begin{equation} lPC_t = \beta_0 + \beta_1PIBtvh_{t+1} + \beta_2txDes_t + \beta_3Spread_{t+4} + u_t \end{equation} The name of my data frame is Dados_R. I need to impose a restriction in the data…
0
votes
1 answer

Summary of model returning NA

I'm new to r and not sure how fix the error I'm getting. Here is the summary of my data: > summary(data) Metro MrktRgn MedAge numHmSales Abilene : 1 Austin-Waco-Hill Country : 6 20-25: 3 Min. …
Brian Sunbury
  • 45
  • 2
  • 9
0
votes
1 answer

Interpreting ridge regression in GridSearchCV

Why are the errors not changing significantly in my cross validated ridge regression model even if I have tried a long list of alphas from 0.01 to 25? CODE from sklearn.linear_model import Ridge from sklearn.model_selection import…
SuperSatya
  • 65
  • 1
  • 6
0
votes
1 answer

First difference estimator...in pandas dataframe

I have a dataframe shown below on which I would like to calculate the first difference estimator between different columns. I found this package, but an unsure of how to implement it...also, are co-variates allowed? I am new to both python and…
Graham Streich
  • 874
  • 3
  • 15
  • 31
0
votes
0 answers

Account for different variable lengths after differenciation in a linear Model in R

Struggling with R. My linear lm() Model contains Variables that are differenced via diff() and variables which are not differenced. The differenced variables are one observation shorter due to differencing. Therefore, the lm() gives the error…
Pizza-Fan
  • 1
  • 2
0
votes
1 answer

Python: Two-way Fixed Effects without independent variable to estimate the residual

Having a multiindex dataframe with the index1: shops, index2: DateTime, and column: LogPrice, I want to take the EntityEffects and TimeEffects out of the data by estimating the residuals of the fixed effects model. yit = constant + αi + δt +…
domod
  • 1
  • 2
-1
votes
1 answer

Print the Sci-kit linear model list

Is it possible to access some kind of list of all the linear models in sklearn? They must be stored somewhere and accessible right?
Tom
  • 109
  • 9
-1
votes
2 answers

why do we use fit() before predict() in LinearRegression

Why do we use fit before giving a LinearRegression model a predict method Imean in this book I didn't even give it a proper training dataset I mean when we give fit doesn't it just fits the data why do we need to predict something which is already…
-1
votes
1 answer

I tried predicting on 5rows of the dataset, but why does it keep predicting on the whole dataset?

So I build a lm model in R on 65OOO rows (mydata) and I want to see only the predictions for the first 5 rows in order to see how good my model predicts. Below you can see the code I wrote to execute this but it keeps predicting the values of all…
1 2 3
9
10