EJERCICIO: MULTICOLINEALIDAD

library(wooldridge) 
library(printr) 
data(hprice1) 
head(force(hprice1), n = 5)
price assess bdrms lotsize sqrft colonial lprice lassess llotsize lsqrft
300 349.1 4 6126 2438 1 5.703783 5.855359 8.720297 7.798934
370 351.5 3 9903 2076 1 5.913503 5.862210 9.200593 7.638198
191 217.7 3 5200 1374 0 5.252274 5.383118 8.556414 7.225481
195 231.8 3 4600 1448 1 5.273000 5.445875 8.433811 7.277938
373 319.1 4 6095 2514 1 5.921578 5.765504 8.715224 7.829630

1.ESTIMACIÓN DEL MODELO

price = α0 + α1(lotsize) + α2(sqrft) + α3(bdrms) + ε

modelo_precio<-lm(price ~ lotsize + sqrft + bdrms, data = hprice1)
library(stargazer) 
stargazer(modelo_precio, title = "Modelo Precio", type = "html", digits = 4)
Modelo Precio
Dependent variable:
price
lotsize 0.0021***
(0.0006)
sqrft 0.1228***
(0.0132)
bdrms 13.8525
(9.0101)
Constant -21.7703
(29.4750)
Observations 88
R2 0.6724
Adjusted R2 0.6607
Residual Std. Error 59.8335 (df = 84)
F Statistic 57.4602*** (df = 3; 84)
Note: p<0.1; p<0.05; p<0.01

2. PRUEBAS DE MULTICOLINEALIDAD

a) ÍNDICE DE CONDICIÓN

library(olsrr) 
col_diag<-ols_coll_diag(modelo_precio)
col_diag
## Tolerance and Variance Inflation Factor
## ---------------------------------------
##   Variables Tolerance      VIF
## 1   lotsize 0.9641236 1.037211
## 2     sqrft 0.7048934 1.418654
## 3     bdrms 0.7159922 1.396663
## 
## 
## Eigenvalue and Condition Index
## ------------------------------
##   Eigenvalue Condition Index   intercept      lotsize       sqrft       bdrms
## 1 3.48158596        1.000000 0.003663034 0.0277802824 0.004156293 0.002939554
## 2 0.45518380        2.765637 0.006800735 0.9670803174 0.006067321 0.005096396
## 3 0.03851083        9.508174 0.472581427 0.0051085488 0.816079307 0.016938178
## 4 0.02471941       11.867781 0.516954804 0.0000308514 0.173697079 0.975025872

Valores del índice de condición menores a 10 indican ausencia de multicolinealidad, entre 10 y 30 indican multicolinealidad moderada y mayores a 30 indican multicolinealidad severa.

b) PRUEBA DE FARRAR-GRAUBER

library(mctest)

fg <- imcdiag(modelo_precio)
fg
## 
## Call:
## imcdiag(mod = modelo_precio)
## 
## 
## All Individual Multicollinearity Diagnostics Result
## 
##            VIF    TOL      Wi      Fi Leamer     CVIF Klein   IND1   IND2
## lotsize 1.0372 0.9641  1.5815  3.2002 0.9819 607.9171     0 0.0227 0.1750
## sqrft   1.4187 0.7049 17.7928 36.0043 0.8396 831.4835     0 0.0166 1.4396
## bdrms   1.3967 0.7160 16.8582 34.1130 0.8462 818.5944     0 0.0168 1.3854
## 
## 1 --> COLLINEARITY is detected by the test 
## 0 --> COLLINEARITY is not detected by the test
## 
## bdrms , coefficient(s) are non-significant may be due to multicollinearity
## 
## R-square of y on all x: 0.6724 
## 
## * use method argument to check which regressors may be the reason of collinearity
## ===================================

Gráfico de la prueba FG

library(fastGraph)

# Usa un valor aproximado del estadístico (ejemplo)
shadeDist(10,
          ddist = "dchisq",
          parm1 = 3,
          col = c("black", "red"),
          lower.tail = FALSE)

La hipótesis nula establece que no existe multicolinealidad. Si el p-value es menor a 0.05, se rechaza la hipótesis nula, indicando evidencia de multicolinealidad entre los regresores

c) FACTORES INFLACIONARIOS DE LA VARIANZA (VIF)

library(car) 
vif_valores<-vif(modelo_precio) 
vif_valores
##  lotsize    sqrft    bdrms 
## 1.037211 1.418654 1.396663

Gráfico de los VIF

barplot(vif_valores, main = "Factores Inflacionarios de la Varianza (VIF)", ylab = "Valor VIF")
abline(h = 5, lty = 2) 
abline(h = 10, lty = 2)

Valores de VIF cercanos a 1 indican ausencia de correlación entre variables explicativas. Valores superiores a 5 sugieren multicolinealidad moderada y mayores a 10 indican multicolinealidad severa.