Giter Site home page Giter Site logo

Comments (2)

bashtage avatar bashtage commented on May 27, 2024

Stata is choosing to use a student's t. Since there is no obvious justification aside from strong assumptions (gaussian residuals), I do not follow that practice. If you use an appropriate student's t to compute the p-value, you will get the same value.

from linearmodels.

spring-haru avatar spring-haru commented on May 27, 2024

It does not seem to be the problem of Student's t vs Gaussian residuals. Rather, the difference seems to be caused by degree of freedom.

Define the following:
N: number of observations
n: number of entities
k: number of parameters

In the example above, linearmodels uses Student's t with degree of freedom df_resid which is N-n-k, whereas Stata uses n-1 (I have not written n-k, see blelow). This is numerically confirmed by the following code:

(resc in the above code is used)

import numpy as np
from scipy.stats import t

pval_manual_calc = 2*t.cdf(resc.tstats['hrsemp'], resc.df_resid)
pval_auto_calc = resc.pvalues['hrsemp']

np.isclose(pval_auto_calc, pval_manual_calc)

which gives True.

To reproduce the Stata result

n_1 = int(resc.entity_info['total']-1)
2*t.cdf(resc.tstats['hrsemp'], n_1)

giving 0.007087663950431981, which is the value Stata returns.

See the following links for discussion on the use of n-1 (not n-k) for Stata.

https://www.statalist.org/forums/forum/general-stata-discussion/general/1479383-df-in-clustered-regression-linear-coefficient-test

https://www.statalist.org/forums/forum/general-stata-discussion/general/1576484-estimating-p-value-from-t-value-in-regression-with-cluster-robust-standard-errors

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.