在其中,R
我可以使用程序包的ncvTest
功能对异方差进行Breusch-Pagan测试car
。Breusch-Pagan检验是卡方检验的一种。
我如何解释这些结果:
> require(car)
> set.seed(100)
> x1 = runif(100, -1, 1)
> x2 = runif(100, -1, 1)
> ncvTest(lm(x1 ~ x2))
Non-constant Variance Score Test
Variance formula: ~ fitted.values
Chisquare = 0.2343406 Df = 1 p = 0.6283239
> y1 = cumsum(runif(100, -1, 1))
> y2 = runif(100, -1, 1)
> ncvTest(lm(y1 ~ y2))
Non-constant Variance Score Test
Variance formula: ~ fitted.values
Chisquare = 1.191635 Df = 1 p = 0.2750001