Multicolinealidad

EC19003 Escolán Chávez, Diana Alejandra GT03

26/5/2021

Carga de datos

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

Estimar el modelo

modelo_est <- lm(formula = price ~ lotsize + sqrft + bdrms, data = hprice1)
library(stargazer)
stargazer(modelo_est, title = "Modelo estimado", type = "text")
## 
## Modelo estimado
## ===============================================
##                         Dependent variable:    
##                     ---------------------------
##                                price           
## -----------------------------------------------
## lotsize                      0.002***          
##                               (0.001)          
##                                                
## sqrft                        0.123***          
##                               (0.013)          
##                                                
## bdrms                         13.853           
##                               (9.010)          
##                                                
## Constant                      -21.770          
##                              (29.475)          
##                                                
## -----------------------------------------------
## Observations                    88             
## R2                             0.672           
## Adjusted R2                    0.661           
## Residual Std. Error      59.833 (df = 84)      
## F Statistic           57.460*** (df = 3; 84)   
## ===============================================
## Note:               *p<0.1; **p<0.05; ***p<0.01
# Para información adicional
summary(modelo_est)
## 
## Call:
## lm(formula = price ~ lotsize + sqrft + bdrms, data = hprice1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -120.026  -38.530   -6.555   32.323  209.376 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -2.177e+01  2.948e+01  -0.739  0.46221    
## lotsize      2.068e-03  6.421e-04   3.220  0.00182 ** 
## sqrft        1.228e-01  1.324e-02   9.275 1.66e-14 ***
## bdrms        1.385e+01  9.010e+00   1.537  0.12795    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 59.83 on 84 degrees of freedom
## Multiple R-squared:  0.6724, Adjusted R-squared:  0.6607 
## F-statistic: 57.46 on 3 and 84 DF,  p-value: < 2.2e-16

Pruebas de multicolinealidad

Indice de condición k(x)

Criterio:

\(k(x)<20\) multicolinealidad leve, no es un problema.

\(20 < k(x) < 30\) multicolinealidad moderada.

\(k(x) ≥ 30\) multicolinealidad severa.

Manual

#Obtener la matriz X
Xmat <- model.matrix(modelo_est)
print(head(Xmat, n=5))
##   (Intercept) lotsize sqrft bdrms
## 1           1    6126  2438     4
## 2           1    9903  2076     3
## 3           1    5200  1374     3
## 4           1    4600  1448     3
## 5           1    6095  2514     4

Usando mctest

library(mctest)
eigprop(mod = modelo_est)
## 
## Call:
## eigprop(mod = modelo_est)
## 
##   Eigenvalues      CI (Intercept) lotsize  sqrft  bdrms
## 1      3.4816  1.0000      0.0037  0.0278 0.0042 0.0029
## 2      0.4552  2.7656      0.0068  0.9671 0.0061 0.0051
## 3      0.0385  9.5082      0.4726  0.0051 0.8161 0.0169
## 4      0.0247 11.8678      0.5170  0.0000 0.1737 0.9750
## 
## ===============================
## Row 2==> lotsize, proportion 0.967080 >= 0.50 
## Row 3==> sqrft, proportion 0.816079 >= 0.50 
## Row 4==> bdrms, proportion 0.975026 >= 0.50

El índice de condición k(x) es 11.8678, hay evidencia de independencia de los regresores del modelo.

Prueba FG

Criterio

\(X_(FG)^2 ≥ VC\) o \(p-value < ∝\) Rechazar \(H_o\)

Usando psych

options(scipen = 999999)
library(psych)
FG_test <- cortest.bartlett(Xmat[,-1])
print(FG_test)
## $chisq
## [1] 31.38122
## 
## $p.value
## [1] 0.0000007065806
## 
## $df
## [1] 3
# Para VC
VC_FG <- qchisq(0.05, FG_test$df,
                lower.tail = FALSE)
print(VC_FG)
## [1] 7.814728
#Graficando con fastGraph
library(fastGraph)
shadeDist(xshade = FG_test$chisq,
          ddist = "dchisq",
          parm1 = FG_test$df,
          lower.tail = FALSE,
          sub = paste("VC:", VC_FG, 
                      "FG:", FG_test$chisq),
          main = "Prueba FG",
          xtic = c(7.81, 31.4))

El estaístico \(X_(FG)^2\) es 31.38122, mientras que el VC es 7.814728 por lo que se rechaza la hipótesis nula \(H_o\), se tiene evidencia de colinealidad en los regresores del modelo.

Usando mctest

library(mctest)
mctest(modelo_est)
## 
## Call:
## omcdiag(mod = mod, Inter = TRUE, detr = detr, red = red, conf = conf, 
##     theil = theil, cn = cn)
## 
## 
## Overall Multicollinearity Diagnostics
## 
##                        MC Results detection
## Determinant |X'X|:         0.6918         0
## Farrar Chi-Square:        31.3812         1
## Red Indicator:             0.3341         0
## Sum of Lambda Inverse:     3.8525         0
## Theil's Method:           -0.7297         0
## Condition Number:         11.8678         0
## 
## 1 --> COLLINEARITY is detected by the test 
## 0 --> COLLINEARITY is not detected by the test

La prueba FG detecta colinealidad en los regresores del modelo.

VIF

Usando car

library(car)
VIF_car <- vif(modelo_est)
print(VIF_car)
##  lotsize    sqrft    bdrms 
## 1.037211 1.418654 1.396663

Usando mctest

library(mctest)
VIC_mc <- mc.plot(modelo_est,
                  vif = 2)

Conclusión: Los regresores del modelo están por debajo de 2, por tanto tienen un valor de varianza aceptable que no infla artificalmente el modelo.