When I am trying to do WLS to correct for heteroskedasticity, I for the following error:
Do you have any suggestions? I noticed that my regression has list length of 13 and the vector for W has 14. I am not sure how to correct for this.
W <- 1 / lm(abs(R40$residuals) ~ R40$fitted.values)$fitted.values^2
R40w <- lm(Market_Cap ~ MarketCap_Lag + Value_traded_ratio + GDP_growthR, data=pdata, weights = W)
summary(R40w)
Error in model.frame.default(formula = Market_Cap ~ MarketCap_Lag + Value_traded_ratio + :
variable lengths differ (found for '(weights)')