6

I am trying to estimate heteroskedasticity in R. I had Eviews available in my college's lab but not at home. I have been trying to use "het.test" package and whites.htest but the value that I get is different from what I get in Eviews. According to the author of the package, it is meant to do the same test as is done in Eviews.

My model looks like A~B+C. Kindly guide me what I am doing wrong.

I 1st run ols for equation A~B+C, after getting results, I clicked View>Residual diagnostics>Heteroscadicity tests>White's (with Include white cross terms) and then Press ok. The result i got was Prob. F(5,27) = 0.2948.

For R, i tried code at this link [this link][1], here is the edited code that i used.

library(vars) 
library(het.test)
dataset <- data.frame(A,B,C)) 
model1 <- VAR(dataset, p = 1) 
whites.htest(model1)

This gave me value of 0.63.

I tried searching this forum but none question seemed related. I am not a programmer not statistician so please pardon my ignorance.

Ferdi
  • 4,882
  • 7
  • 42
  • 62
Faseeh
  • 63
  • 1
  • 1
  • 6

1 Answers1

13

The whites.htest() function implements White's test for heteroskedasticity for vector autoregressions (VAR). It requires a varest object as input. However, from your description it seems that your model is not a VAR (vector autoregression) but a simple linear model.

Hence, the model should be estimated by lm() as previously suggested in the comments. Then you can use the bptest() function from the lmtest package to carry out White's test. The latter requires that you set up the terms in the auxiliary model yourself. It should look like this:

m <- lm(A ~ B + C, data = dataset)
bptest(m, ~ B*C + I(B^2) + I(C^2), data = dataset)

Note that B*C includes the main effects and their interaction (= product). Equivalently - and maybe somewhat more explicitly - we could also specify the auxiliary model as ~ A + B + I(A*B) + I(A^2) + I(B^2).

You can also look at

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

for a worked example.

Achim Zeileis
  • 13,510
  • 1
  • 29
  • 53