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

Different standard error estimations from linearmodels and statsmodels package

Here are reproducible codes: import pandas as pd # Outer is entity, inner is time entity = list(map(chr,range(65,91))) time = list(pd.date_range('1-1-2014',freq='A', periods=4)) index = pd.MultiIndex.from_product([entity, time]) df =…
StatsNoob
  • 360
  • 1
  • 5
  • 15
1
vote
0 answers

Why does using lmer result in including quadratic fixed terms?

Running lmer results in additional quadratic fixed terms. I don't think this is correct and I don't have a reason to include quadratic terms in the formula. I was expecting only linear main effects and all interaction…
1
vote
1 answer

Constraining select coefficients to be the same across equations in a SUR system

I want to estimate Labor Force Participation Rates for different age groups in a system of seemingly unrelated regressions (SUR), regressing them on some age group specific variables and shared birth-cohort dummies. This is the typical cohort-based…
1
vote
0 answers

The differences between the function of anova and summary to analyze the linear model in R

I construct a liner model.But the results are either diffetent or same when the model be complicated or easy repectively. Is there someone know the reason? This is the different results. > lm_all <-…
ChuDingjin
  • 11
  • 3
1
vote
0 answers

regression using lm with excluding

I am solving a question related to my course. the question is: Run linear model using training data with “Florence” as outcome variable, while using “Gender”, “FirstPurch”, and “all book categories” as predictors and give the summary of the model.…
Riddle2795
  • 49
  • 6
1
vote
1 answer

asreg (Stata) and linearmodels.panel.model.FamaMacbeth (Python) give different results

I have a .dta file of loan data over the course of 10 years, and want to run a Fama-Macbeth regression on the data to estimate risk premiums on loan returns. For a quick overview of what Fama-Macbeth regression is, here's an excerpt from an older…
1
vote
0 answers

ValueError: Series can only be used with a 2-level MultiIndex

I tried implementing the following codes but came up with a 2-level multiindex error. Can you please help: data = np.array([(1, 2, 3), (4, 5, 6), (7, 8, 9)], dtype=[("a", "i4"), ("b", "i4"), ("c", "i4")]) df3 = pd.DataFrame(data,…
Jonathan S
  • 29
  • 2
  • 6
1
vote
1 answer

How to include year fixed effect (in a daily panel data)

I am working on a panel dataset that includes daily stock returns of 450 firms for 5 years and daily ESG score(momentum based) for 5 years. I want to regress stock return on daily ESG scores, keeping Firm and year fixed effect. I have used…
Asif Zahir
  • 15
  • 2
1
vote
1 answer

How can i get predictions with CI from lmerTest models?

We are currently working with plant phenology. We built a linear mixed model for each species present in the study area. We set Days From Snowmelt (The sum of days from snowmelt to the visit day along the summer) as the response variable while Mean…
1
vote
2 answers

Can I pretty print the output of linearmodels.panel.results.compare() when I convert a Jupyter Notebook to PDF?

I use Python to analyze data in Jupyter Notebooks, which I convert to PDFs to share with coauthors (jupyter nbconvert --to pdf). I often use linearmodels.panel.results.compare() to compare panel regression estimates from the linearmodels…
Richard Herron
  • 9,760
  • 12
  • 69
  • 116
1
vote
0 answers

Fit Linear Mixed-Effects Models (R lme4 formula vs python statsmodels)

I would like to compute a Principal Variance Component analysis which combines a PCA with a mixed effect linear model to identify batch effects. (https://www.niehs.nih.gov/research/resources/software/biostatistics/pvca/index.cfm) I have checked the…
xPae
  • 11
  • 1
1
vote
1 answer

Output linearmodels regression summary as latex

How can I print out the summary table of a fitted linearmodels object as latex? For example, how can I print res as latex code? # Libraries import pandas as pd from linearmodels.panel import PanelOLS from linearmodels.datasets import wage_panel #…
Arturo Sbr
  • 5,567
  • 4
  • 38
  • 76
1
vote
0 answers

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

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…
1
vote
1 answer

Changing the moderating variables used in a linear model in R? (Two-way ANOVA)

I am carrying out a two-way ANOVA in R to analyse an experiment. I have a long list of moderating variables I need to test for my partner company in the model (mainly numeric, continuous scale items measures). This would be the basic model of the…
1
vote
0 answers

Saving multiple linear regression models in a loop

I am trying a multi linear regression with 4 independent parameters which are compared against these parameters for a class with label 0 to linearly fit the model. from sklearn import linear_model from pandas import DataFrame covariates =…
Arjun
  • 107
  • 1
  • 1
  • 6
1 2
3
9 10