Use VIF test

1

I'm trying to run the VIF test for a two-stage MQO model, but the following warning appears:

  Warning message: In v1 * v2: length of largest object is not   multiple of the length of the smaller object

Follow the template:

lm(MEDIA_9EF_JUNTO ~ nona_D_esperado + ID_DEPENDENCIA_ADM + ID_LOCALIZACAO + nona_TAXA_PARTICIPACAO_9EF + ICG + NIVEL_SOCIO_ECONOMICO + Zlocalização, data=nona_serie_final_excluido))

follows the class of variables as well:

##VERIFICANDO CLASSES

> class(quinta_serie_final_excluido$MEDIA_5EF_JUNTO)
[1] "numeric"
> class(quinta_D_esperado)
[1] "numeric"
> class(quinta_serie_final_excluido$ID_DEPENDENCIA_ADM)
[1] "integer"
> class(quinta_serie_final_excluido$ID_LOCALIZACAO)
[1] "integer"
> class(quinta_TAXA_PARTICIPACAO_5EF)
[1] "numeric"
> class(quinta_serie_final_excluido$ICG)
[1] "integer"
> class(quinta_serie_final_excluido$NIVEL_SOCIO_ECONOMICO)
[1] "integer"
> class(quinta_serie_final_excluido$Zlocalização)
[1] "integer"
    
asked by anonymous 24.02.2018 / 23:43

1 answer

2

To perform variance inflation factor (VIF), in a regression analysis, do:

dataset<-data.frame(v1=c(4,5,5,5,6,7,6,6,7,7),v2=c(5,6,6,4,3,2,4,5,6,7),v3=c(4,5,6,6,7,8,5,6,6,7))

reg<-lm(v1~v2+v3,data=dataset)
summary(reg)

#Call:
#lm(formula = v1 ~ v2, data = dataset, subset = v3)

#Residuals:
#Min      1Q  Median      3Q     Max 
#-0.8624 -0.2271  0.1514  0.1651  0.6239 

#Coefficients:
        #Estimate Std. Error t value Pr(>|t|)    
#(Intercept)   7.8073     0.4323  18.060 9.07e-08 ***
#v2           -0.4862     0.1322  -3.679  0.00623 ** 
#---
#Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

#Residual standard error: 0.4363 on 8 degrees of freedom
#Multiple R-squared:  0.6286,   Adjusted R-squared:  0.5821 
#F-statistic: 13.54 on 1 and 8 DF,  p-value: 0.006225

Now, the test you want:

library(car)

vif(reg)
#v2      v3 
#1.16129 1.16129 
    
25.08.2018 / 00:04