7
$\begingroup$

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.

$\endgroup$
8
  • 3
    $\begingroup$ It is going to be hard to say without more information. Can you paste in the code & output from the 3 tests? Can you say more about your data & your model? Etc. $\endgroup$ Commented Jun 4, 2015 at 12:58
  • $\begingroup$ @gung, please see as i have added details. $\endgroup$
    – Faseeh
    Commented Jun 4, 2015 at 17:52
  • $\begingroup$ Why not lm? Why VAR? $\endgroup$ Commented Jun 4, 2015 at 17:53
  • $\begingroup$ @T C..Thank you for reply.. i must say, it was there in the code that i quoted, :( can you guide me to the correct usage? $\endgroup$
    – Faseeh
    Commented Jun 4, 2015 at 17:56
  • $\begingroup$ Just write lm(A ~ B + C, data = dataset) where you have VAR right now. $\endgroup$ Commented Jun 4, 2015 at 17:58

1 Answer 1

14
$\begingroup$

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.

$\endgroup$
5
  • $\begingroup$ Thank you Sir. I tried it and finally reached correct answer. Thank you so much for help. $\endgroup$
    – Faseeh
    Commented Jun 5, 2015 at 9:43
  • 1
    $\begingroup$ @Faseeh, if this has resolved your question, please consider accepting it by clicking the check mark below the vote total on the left. $\endgroup$ Commented Jun 5, 2015 at 9:49
  • $\begingroup$ @gung, thank you for guiding me, i will keep visiting. :) $\endgroup$
    – Faseeh
    Commented Jun 5, 2015 at 9:53
  • $\begingroup$ Sorry to reheat the thread, but what would be an example of a specification od White's test for three independent variables look like, i.e. A ~ B + C + D? $\endgroup$
    – kwadratens
    Commented Sep 28, 2022 at 14:42
  • 2
    $\begingroup$ You need to include all regressors B + C + D, all squared regressors I(B^2) + I(C^2) + I(D^2), and all pairwise interactions B:C + B:D + C:D. A somewhat shorter notation for this is ~ (B + C + D)^2 + I(B^2) + I(C^2) + I(D^2). $\endgroup$ Commented Oct 5, 2022 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.