The question is straightforward: How to implement White test (a test for heteroscedasticity) for a simple linear regression model (lm object) in R?
I have tried "whites.htest(var.model)", however, it requires an input of varest object.
I learned that it requires to regress the squared of residuals with all squared variables, as well as their interaction terms. However, there seems no functions in R to implement this.
Can anyone give an example of it?
for example: if i have 4 variables in a regression equation lm(y~A+B+C+D). How should I write the white test code?
Note: my question is more general than this question that has been asked before: White's test for heteroskedasticity in R It only explains how to implement when there are only two variables. However, what if I have more than 3 variables? How could I express the regression equation to implement White test?