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

Integrate Brush-Pegan test for checking heteroskedasticity #101

Closed
sourish-cmi opened this issue Feb 13, 2023 · 2 comments · Fixed by #102
Closed

Integrate Brush-Pegan test for checking heteroskedasticity #101

sourish-cmi opened this issue Feb 13, 2023 · 2 comments · Fixed by #102
Assignees
Labels
good first issue Good for newcomers

Comments

@sourish-cmi
Copy link
Collaborator

sourish-cmi commented Feb 13, 2023

Brush-Pegan test for checking heteroskedasticity
Integrate Brush-Pegan test (aka. WhiteTest) from HypothesisTest package

Describe the solution you'd like
Possible code would look like:

container = fit(@formula(y~X1+X2),DataFrame,LinearRegression())
BPTest(container)
@sourish-cmi sourish-cmi added the good first issue Good for newcomers label Feb 13, 2023
@sourish-cmi sourish-cmi self-assigned this Feb 13, 2023
@sourish-cmi sourish-cmi changed the title Integrate Brush-Pegan test for checking homoscadasticity Integrate Brush-Pegan test for checking heteroskedasticity Feb 15, 2023
@sourish-cmi
Copy link
Collaborator Author

sourish-cmi commented Feb 15, 2023

Here is the code for the Brush-Pegan test for checking heteroskedasticity

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

@ShouvikGhosh2048 can you please add this function in the getter and add a PR? I am adding the test below:

julia> using CRRao, RDatasets, StatsModels
julia> df = dataset("datasets", "mtcars")
julia> model = fit(@formula(MPG ~ HP + WT+Gear), df, LinearRegression());
julia> BP_tst = BPTest(model,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

julia> pvalue(BP_tst)
0.46203539153321815

@sourish-cmi
Copy link
Collaborator Author

I cross-checked the result with R - the result is different. I raised this issue with HypothesisTests.jl

Let's go ahead and integrate it in any way.

@sourish-cmi sourish-cmi linked a pull request Feb 16, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants