Comments (5)
If you copy the file here https://www.wiley.com/legacy/wileychi/baltagi/supp/Gasoline.dat to the clipboard, and then run:
import pandas as pd
df = pd.read_clipboard()
df2 = df.set_index(["COUNTRY","YEAR"])
df2["CONST"]=1
y=df2.LGASPCAR
x = df2[["CONST","LINCOMEP", 'LRPMG', 'LCARPCAP']]
res = lm.RandomEffects(y,x).fit()
print(res)
RandomEffects Estimation Summary
================================================================================
Dep. Variable: LGASPCAR R-squared: 0.8293
Estimator: RandomEffects R-squared (Between): 0.7099
No. Observations: 342 R-squared (Within): 0.8363
Date: Tue, Sep 26 2023 R-squared (Overall): 0.7309
Time: 17:19:27 Log-likelihood 320.02
Cov. Estimator: Unadjusted
F-statistic: 547.40
Entities: 18 P-value 0.0000
Avg Obs: 19.000 Distribution: F(3,338)
Min Obs: 19.000
Max Obs: 19.000 F-statistic (robust): 547.40
P-value 0.0000
Time periods: 19 Distribution: F(3,338)
Avg Obs: 18.000
Min Obs: 18.000
Max Obs: 18.000
Parameter Estimates
==============================================================================
Parameter Std. Err. T-stat P-value Lower CI Upper CI
------------------------------------------------------------------------------
CONST 1.9967 0.1843 10.832 0.0000 1.6341 2.3593
LINCOMEP 0.5550 0.0591 9.3861 0.0000 0.4387 0.6713
LRPMG -0.4204 0.0400 -10.515 0.0000 -0.4990 -0.3418
LCARPCAP -0.6068 0.0255 -23.784 0.0000 -0.6570 -0.5567
Constants, and any other variables, have to be explicitly added, unlike some other software. This is by design and consistent with the philosophy of Python - explicit is better than implicit.
from linearmodels.
I've closed this since the code appears to be working as expected.
from linearmodels.
Are you sure you are not doing something incorrectly? LM is directly tested against stata and produces the same results (at with the same as Stata 13, but RE is so old, unlikely to change).
from linearmodels.
Here are results from Python, STATA, and from a page in a Econ book:
STATA
Copy of page 21 of Badi Baltagi's text Econometric Analysis of Panel Data showing the results of different RE specifications.
from linearmodels.
What if you include a constant in your model?
from linearmodels.
Related Issues (20)
- wald_test HOT 4
- Option to avoid MissingValueWarning warning. HOT 3
- Suggestion: Implement a `.remove_data` function for Results
- Min. obs pr Entities/Time Periods is sometimes reported as 0 HOT 3
- Small sample correction clustered avaialble? HOT 2
- Clustered standard errors in `lineramodels` and `statsmodels` HOT 3
- Fixed-effect `p-value` with clustered covariance differs from Stata HOT 2
- PanelOLS : Dropping absorbed variables doesn't work with sample weights HOT 2
- 14 tests fail HOT 2
- ENH: Implement 2+ fixed-effect with multi-way clustering OLS
- Estimated Effects in random effect HOT 7
- Fixed effects std. error and p-values HOT 2
- Sanitize extra text from summary
- Interaction terms for Categorical Variables in a RE Model HOT 4
- Typo in doc in Driscoll-Kraay formula
- How to fit LIML with 1 endogenous variable, 1 instrument, including an intercept HOT 11
- MemoryError with IV2SLS
- `panel_structure_stats()` returns a generic `numpy` error if `ids` are negative
- Typos in the documentation (Instrumental Variable Estimation, Formulas and Mathematical Detail) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linearmodels.