Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different p-value compare to R #285

Open
sourish-cmi opened this issue Feb 16, 2023 · 0 comments
Open

Different p-value compare to R #285

sourish-cmi opened this issue Feb 16, 2023 · 0 comments

Comments

@sourish-cmi
Copy link

Hi

In R, I did the Whites' test (aka. Brush Pegan Test). I found the p-value is different. Can you please have a look and check if there is a mistake in my code.

The R-code and output

R> attach(mtcars)
R> model = lm(mpg~hp+wt+gear,mtcars)
R> library(lmtest)
R> bptest(model,data=mtcars)

	studentized Breusch-Pagan test

data:  model
BP = 1.3627, df = 3, p-value = 0.7143

The Julia code and output

using HypothesisTests

function BPTest(container:: FrequentistRegression, data::DataFrame) 
       fm_frame = ModelFrame(container.formula, data);
       X=modelmatrix(fm_frame)
       e = residuals(container)
       BP_Test1 = WhiteTest(X,e);
       return(BP_Test1);
end
BP_tst = BPTest(mod1,train_df)

White's (or Breusch-Pagan's) test for heteroskedasticity
--------------------------------------------------------
Population details:
    parameter of interest:   T*R2
    value under h_0:         0
    point estimate:          8.73554

Test summary:
    outcome with 95% confidence: fail to reject h_0
    one-sided p-value:           0.4620

Details:
    T*R^2 statistic:        8.73554
    degrees of freedom:     9
    type:                   White

pvalue(BP_tst)
0.46203539153321815

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant