Code Monkey home page Code Monkey logo

Comments (5)

bashtage avatar bashtage commented on August 10, 2024 1

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.

bashtage avatar bashtage commented on August 10, 2024 1

I've closed this since the code appears to be working as expected.

from linearmodels.

bashtage avatar bashtage commented on August 10, 2024

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.

brianferrell787 avatar brianferrell787 commented on August 10, 2024

Here are results from Python, STATA, and from a page in a Econ book:
STATA
image

Copy of page 21 of Badi Baltagi's text Econometric Analysis of Panel Data showing the results of different RE specifications.
image

Python
image
image

from linearmodels.

bashtage avatar bashtage commented on August 10, 2024

What if you include a constant in your model?

from linearmodels.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.