Testing on Heteroscedasticity with White Test

Viewed 183

I have already tested for heteroskedasticity with the Breusch-Pagan Test and found that the test came out positive.

Based on the template that I have from a book, one should now also check with the White test whether heteroskedasticity is present.

Unfortunately, the test does not want to work for me:/

This is how my calculation looks like:

install.packages(c("AER"))
library(AER)


bptest(r1, varformula = ~ log(intr) + log(sale_py_at_py) + log(R_at_py) 
       + log(p_con) + log(txt) + factor(Dummy_SIC)
       + I(log(intr))^2 + I(log(sale_py_at_py))^2 + I(log(R_at_py))^2 
        + I(log(p_con))^2 + I(log(txt))^2 + I(factor(Dummy_SIC))^2
        + I(log(intr)*log(sale_ap_at_py)) + I(log(intr)*log(R_at_py))
        + I(log(intr)*log(p_con)) + I(log(intr)*log(txt)) 
        + I(log(sale_ap_at_py)*loglog(R_at_py)) 
        + I(log(sale_ap_at_py)*loglog(p_con))
         + I(log(sale_ap_at_py)*loglog(txt))
         + I(log(R_at_py)*loglog(p_con)) + I(log(R_at_py)*loglog(txt))
         + I(log(p_con)*loglog(txt)) + I(log(intr)*factor(Dummy_SIC))
         + I(log(sale_py_at_py)*factor(Dummy_SIC))
         + I(log(R_at_py)*factor(Dummy_SIC)) 
         + I(log(p_con)*factor(Dummy_SIC)) 
          + I(log(txt)*factor(Dummy_SIC)), data = r1)

This is the error:

error in x$terms %||% attr(x, "terms") %||% stop("no terms component nor attribute") : no terms component nor attribute

Where is my error in the calculation or what do I have to do differently?

Explanation of variables:

marketingspending= marketing spending, intr= interest rate, sale_py_at_py= sale(t-1)/asset(t-1), R_at_py= 1/asset(t-1), txt= tax, p_con= consumption(t-1), DummySIC means that I divided them into 8 groups of segments (sic) the company is working in (Group 0-7). And if the company is in the Group 1 it gets a 1 for DummySIC1 and 0 in every other Dummy-group (and so on for every group).

My original regression looks like this:

lm.01.1 <-lm(marketingspending ~ intr + sale_py_at_py + R_at_py + txt 
           + dt + factor(Dummy_SIC), data=Relevante_V03)

Afterwards I had to make changes so that the conditions of a regression are fulfilled (checked by gvlma()). For this, I deleted extreme values and took log(). So the regression looks like this:

lm.01.3 <-lm(log(marketingspending) ~ log(intr) + log(sale_py_at_py) 
             + log(R_at_py) + log(p_con) + log(txt) + factor(Dummy_SIC)
             , data=r1) 

Edit 1:

I applied the suggestions of the comments so the function looks now like this:

 bptest(lm.01.3, varformula = ~ log(intr) + log(sale_py_at_py) + log(R_at_py) 
       + log(p_con) + log(txt) + factor(Dummy_SIC)
       + I(log(intr))^2 + I(log(sale_py_at_py))^2 + I(log(R_at_py))^2 
        + I(log(p_con))^2 + I(log(txt))^2 + I(factor(Dummy_SIC))^2
        + I(log(intr)*log(sale_py_at_py)) + I(log(intr)*log(R_at_py))
        + I(log(intr)*log(p_con)) + I(log(intr)*log(txt)) 
        + I(log(sale_py_at_py)*log(R_at_py)) 
        + I(log(sale_py_at_py)*log(p_con))
         + I(log(sale_py_at_py)*log(txt))
         + I(log(R_at_py)*log(p_con)) + I(log(R_at_py)*log(txt))
         + I(log(p_con)*log(txt)) + I(log(intr)*factor(Dummy_SIC))
         + I(log(sale_py_at_py)*factor(Dummy_SIC))
         + I(log(R_at_py)*factor(Dummy_SIC)) 
         + I(log(p_con)*factor(Dummy_SIC)) 
          + I(log(txt)*factor(Dummy_SIC)), data = r1)

Now I get the following error:

Error in lm.fit(X, y) : 0 (non-NA) cases

Does that mean I can't use the white test because of the factor variable?

Extra information:

I am doing a regression to test the influences on marketing spending.

0 Answers
Related