Test for Homoscedesticity in R Without BP Test

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Test for Homoscedesticity in R Without BP Test

Deepak Singh
Respected Sir,
I am doing a project on multiple linear model fitting and in that project I
have to test Homoscedesticity of errors I have google for the same and
found bptest for the same but in R version 3.2.4 bp test is not available.
So please suggest me a test on homoscedesticity ASAP as we have to submit
our report on 7-04-2016.

P.S. : I have plotted residuals against fitted values and it is less or
more random.

Thank You !

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Test for Homoscedesticity in R Without BP Test

John C Frain
You might "google Breusch Pagan test r" and find that the test is
implemented in lmtest package.
On 4 Apr 2016 17:28, "Deepak Singh" <[hidden email]> wrote:

> Respected Sir,
> I am doing a project on multiple linear model fitting and in that project I
> have to test Homoscedesticity of errors I have google for the same and
> found bptest for the same but in R version 3.2.4 bp test is not available.
> So please suggest me a test on homoscedesticity ASAP as we have to submit
> our report on 7-04-2016.
>
> P.S. : I have plotted residuals against fitted values and it is less or
> more random.
>
> Thank You !
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Test for Homoscedesticity in R Without BP Test

R help mailing list-2
In reply to this post by Deepak Singh
Hi Deepak,

In econometrics there is another test very often used : the white test.
The white test is based on the comparison of the estimated variances of residuals when the model is estimated by OLS under the assumption of homoscedasticity and when the model is estimated by OLS under the assumption of heteroscedastic.


The White test with R

install.packages("bstats")
library(bstats)
white.test(LinearModel)



Hope this helps.

Sacha





________________________________
De : Deepak Singh <[hidden email]>
À : [hidden email]
Envoyé le : Lundi 4 avril 2016 10h40
Objet : [R] Test for Homoscedesticity in R Without BP Test


Respected Sir,
I am doing a project on multiple linear model fitting and in that project I
have to test Homoscedesticity of errors I have google for the same and
found bptest for the same but in R version 3.2.4 bp test is not available.
So please suggest me a test on homoscedesticity ASAP as we have to submit
our report on 7-04-2016.

P.S. : I have plotted residuals against fitted values and it is less or
more random.

Thank You !

    [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Test for Homoscedesticity in R Without BP Test

Achim Zeileis-4
In reply to this post by Deepak Singh
On Mon, 4 Apr 2016, Deepak Singh wrote:

> Respected Sir,
> I am doing a project on multiple linear model fitting and in that project I
> have to test Homoscedesticity of errors I have google for the same and
> found bptest for the same but in R version 3.2.4 bp test is not available.

The function is called bptest() and is implemented in package "lmtest"
which is available for current versions of R, see
https://CRAN.R-project.org/package=lmtest

To install it, run:
install.packages("lmtest")

And then to load the package and try the function:
library("lmtest")
example("bptest")

> So please suggest me a test on homoscedesticity ASAP as we have to submit
> our report on 7-04-2016.
>
> P.S. : I have plotted residuals against fitted values and it is less or
> more random.
>
> Thank You !
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Test for Homoscedesticity in R Without BP Test

Achim Zeileis-4
In reply to this post by R help mailing list-2
On Mon, 4 Apr 2016, varin sacha via R-help wrote:

> Hi Deepak,
>
> In econometrics there is another test very often used : the white test.
> The white test is based on the comparison of the estimated variances of
> residuals when the model is estimated by OLS under the assumption of
> homoscedasticity and when the model is estimated by OLS under the
> assumption of heteroscedastic.

The White test is a special case of the Breusch-Pagan test using a
particular specification of the auxiliary regressors: namely all
regressors, their squares and their cross-products. As this specification
makes only sense if all regressors are continuous, many implementations
have problems if there are already dummy variables, interactions, etc. in
the regressor matrix. This is also the reason why bptest() from "lmtest"
uses a different specification by default. However, you can utilize the
function to carry out the White test as illustrated in:

example("CigarettesB", package = "AER")

(Of course, the AER package needs to be installed first.)

> The White test with R
>
> install.packages("bstats")
> library(bstats)
> white.test(LinearModel)

That package is no longer on CRAN as it took the code from bptest()
without crediting its original authors and released it in a package that
conflicted with the original license. Also, the implementation did not
check for potential problems with dummy variables or interactions
mentioned above.

So the bptest() implementation from "lmtest" is really recommend. Or
alternatively ncvTest() from package "car".

> Hope this helps.
>
> Sacha
>
>
>
>
>
> ________________________________
> De : Deepak Singh <[hidden email]>
> À : [hidden email]
> Envoyé le : Lundi 4 avril 2016 10h40
> Objet : [R] Test for Homoscedesticity in R Without BP Test
>
>
> Respected Sir,
> I am doing a project on multiple linear model fitting and in that project I
> have to test Homoscedesticity of errors I have google for the same and
> found bptest for the same but in R version 3.2.4 bp test is not available.
> So please suggest me a test on homoscedesticity ASAP as we have to submit
> our report on 7-04-2016.
>
> P.S. : I have plotted residuals against fitted values and it is less or
> more random.
>
> Thank You !
>
>    [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Test for Homoscedesticity in R Without BP Test

Deepak Singh
I have tried and got the result.
Thank you every one.


On Tue, Apr 5, 2016 at 12:58 AM, Achim Zeileis <[hidden email]>
wrote:

> On Mon, 4 Apr 2016, varin sacha via R-help wrote:
>
> Hi Deepak,
>>
>> In econometrics there is another test very often used : the white test.
>> The white test is based on the comparison of the estimated variances of
>> residuals when the model is estimated by OLS under the assumption of
>> homoscedasticity and when the model is estimated by OLS under the
>> assumption of heteroscedastic.
>>
>
> The White test is a special case of the Breusch-Pagan test using a
> particular specification of the auxiliary regressors: namely all
> regressors, their squares and their cross-products. As this specification
> makes only sense if all regressors are continuous, many implementations
> have problems if there are already dummy variables, interactions, etc. in
> the regressor matrix. This is also the reason why bptest() from "lmtest"
> uses a different specification by default. However, you can utilize the
> function to carry out the White test as illustrated in:
>
> example("CigarettesB", package = "AER")
>
> (Of course, the AER package needs to be installed first.)
>
> The White test with R
>>
>> install.packages("bstats")
>> library(bstats)
>> white.test(LinearModel)
>>
>
> That package is no longer on CRAN as it took the code from bptest()
> without crediting its original authors and released it in a package that
> conflicted with the original license. Also, the implementation did not
> check for potential problems with dummy variables or interactions mentioned
> above.
>
> So the bptest() implementation from "lmtest" is really recommend. Or
> alternatively ncvTest() from package "car".
>
>
> Hope this helps.
>>
>> Sacha
>>
>>
>>
>>
>>
>> ________________________________
>> De : Deepak Singh <[hidden email]>
>> À : [hidden email] Envoyé le : Lundi 4 avril 2016 10h40
>> Objet : [R] Test for Homoscedesticity in R Without BP Test
>>
>>
>> Respected Sir,
>> I am doing a project on multiple linear model fitting and in that project
>> I
>> have to test Homoscedesticity of errors I have google for the same and
>> found bptest for the same but in R version 3.2.4 bp test is not available.
>> So please suggest me a test on homoscedesticity ASAP as we have to submit
>> our report on 7-04-2016.
>>
>> P.S. : I have plotted residuals against fitted values and it is less or
>> more random.
>>
>> Thank You !
>>
>>    [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.