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

Installing python package linear models using the .tar.gz file

I'm trying to install linearmodels with this file (linearmodels-4.20.tar.gz) because of company VPN blocking the simpler pip install linearmodels. I tried with seaborn the command below from the anaconda prompt and it worked. pip install…
Andrea2810
  • 11
  • 4
0
votes
1 answer

Results from Python linearmodels PanelOLS and Stata areg differ

For a fixed effect model I was planning to switch from Stata's areg to Python's linearmodels.panel.PanelOLS. But the results are different. In Stata I get R-squared = 0.6047 and in Python I get R-squared = 0.1454. How come that I get so different…
Wuff
  • 257
  • 1
  • 8
0
votes
1 answer

How to call a python module in a function definition

How do I write a function definition, when one of the variables in the def needs to call something related to a module? Implementable example: df is a database with some columns: Loc Day A B 1 1 2 4 1 2 4 2 2 3 7 9 3 4 1 …
Maxim Lott
  • 368
  • 4
  • 15
0
votes
1 answer

lsmeans for a piecewise linear mixed-effects model on r

I originally posted this question on Cross Validated Stackexchange, and got no answer. Therefore I decided to give it a go here. I am trying to figure out how to obtain lsmeans for a piecewise linear mixed-effects model (fitted with the nlme…
Leo
  • 1
  • 1
0
votes
2 answers

Save summary as image using Linear Models

I am trying to save as PNG File the summary of some regressions that I am doing using the package linearmodels from linearmodels.iv import IV2SLS [...] modelIV =IV2SLS.from_formula(formulaIV,Data).fit(cov_type='unadjusted') print(modelIV.summary) I…
0
votes
1 answer

How to do test of equality of coefficient for 2SLS in Statsmodels or Linearmodels?

So if I ran an experiment with multiple treatment groups and a control, I would analyse the results using Statsmodel ols to see if any of the treatment group were statistically different from the control group: y ~ C(treatment_group,…
Jameson
  • 167
  • 2
  • 11
0
votes
0 answers

I am very new to python, I want to increase the font size of my legend in sns.lmplot

sns.set_style("white") g =sns.lmplot(x="diet_19", y="Se_inv_19", hue="taxa", data=Data, markers= ["o","v","s","*","P","x"]); ###for Axes plt.ylim(-5, 15) plt.xlim(-0.5,…
0
votes
0 answers

in linearmodels is the *.f_statistic null hypothesis really that "All parameters ex. constant not zero"?

The documentation on https://bashtage.github.io/linearmodels/panel/panel/linearmodels.panel.results.RandomEffectsResults.f_statistic.html?highlight=f%20statistic#linearmodels.panel.results.RandomEffectsResults.f_statistic reports that *.f_statistic…
jdawg
  • 1
  • 1
0
votes
2 answers

How to run a linear model on a certain group of respondents?

I am trying to run a linear model, but only on a certain group of respondents. I found sample code online that said to use the gapminder function to isolate the group of respondents. Here, I only want to include respondents who have a value of 1 in…
sierra
  • 1
  • 1
0
votes
1 answer

Interpreting Hausman Test Results Python (Linearmodels)

Here is my code: ivmod = IV2SLS(y, None, df['VariableOne'], df['RandomVariable']) res_2sls = ivmod.fit() res_2sls.wu_hausman() Here is the test result: Wu-Hausman test of exogeneity H0: All endogenous variables are exogenous Statistic:…
0
votes
0 answers

Add predictions using models with interactions in R

I am using modelr for adding predictions based on a linear regression model with interactions. The question is does add_predictions() work with interactions? df <- tibble::tibble( x1 = sort(runif(100)), x2 = sort(runif(100)), y = 2*x1 +…
Rtist
  • 3,825
  • 2
  • 31
  • 40
0
votes
0 answers

Singularity in Linear Mixed Effects Models

Dataset Description: I use a dataset with neuropsychological (np) tests from several subjects. Every subject has more than one tests in his/her follow up i.e one test per year. I study the cognitive decline in these subjects. The information that I…
0
votes
0 answers

Why is Panel OLS in Python giving me the error 'dependent and exog must have the same number of observations' when they are the same length?

I'm trying to use Panel OLS from linearmodels, but get a message saying that the endogenous and exogenous variables aren't the same length. According to the code in the PanelOLS function, y.shape[0] != x.shape[0], but when I print both shapes it's…
0
votes
0 answers

How can I do partial F Test in python linearmodels?

I want to do partial F Test in python linearmodels, is there any command that I can to this? import numpy as np import pandas as pd import linearmodels.iv as iv f = 'ln_assaults ~ 1 + [attend_v + attend_m + attend_n ~ pr_attend_v + pr_attend_m +…
Jinze
  • 3
  • 1
0
votes
1 answer

How can we interpret feature importances for Stochastic Gradient Descent Classifier?

I have a SGDClassifier model trained with scikit-learn. I extract features names with .get_feature_names() and coefficients with .coef_ I combine the 2 columns in a dataframe like this : feature value hiroshima 3.918584 wildfire …