La base de datos contiene los valores correspondientes a cinco índices elaborados por el Instituto V-Dem para un total de 179 países en el año 2023: * Electoral democracy index (v2x_polyarchy) * Liberal component index (v2x_liberal) * Participatory component index (v2x_partip) * Deliberative component index (v2xdl_delib) * Egalitarian component index (v2x_egal)

Se proponen las siguientes hipótesis: * H1: El componente participativo (v2x_partip) y el deliberativo (v2xdl_delib) explican el índice de democracia electoral (v2x_polyarchy). * H2: El componente participativo (v2x_partip), el deliberativo (v2xdl_delib) y el igualitario (v2x_egal) explican el índice de democracia electoral (v2x_polyarchy). * H3: El componente participativo (v2x_partip), el deliberativo (v2xdl_delib), el igualitario (v2x_egal) y el liberal (v2x_liberal) explican el índice de democracia electoral (v2x_polyarchy). * H4: El componente participativo (v2x_partip), el igualitario (v2x_egal) y el liberal (v2x_liberal) explican el índice de democracia electoral (v2x_polyarchy).

Pregunta 1

Aplica un regresión para comprobar la H2 y responde lo siguiente:

linkADrive='https://docs.google.com/spreadsheets/d/e/2PACX-1vSQ8GeWPSGhq0SaoWyGRfxEN5fm1hLsYDPFpyGgjlID479tGPwwdMZkfq_j6f4SeH7MYwcGPrIqeQy8/pub?gid=1383566652&single=true&output=csv'
vdem = read.csv(linkADrive)
str(vdem)
## 'data.frame':    179 obs. of  6 variables:
##  $ country_name : chr  "Mexico" "Suriname" "Sweden" "Switzerland" ...
##  $ v2x_polyarchy: num  0.53 0.75 0.88 0.89 0.66 0.69 0.82 0.08 0.19 0.51 ...
##  $ v2x_liberal  : num  0.48 0.84 0.98 0.96 0.86 0.85 0.9 0.04 0.15 0.75 ...
##  $ v2x_partip   : num  0.65 0.57 0.65 0.88 0.38 0.56 0.57 0.31 0.38 0.56 ...
##  $ v2xdl_delib  : num  0.55 0.77 0.91 0.98 0.85 0.87 0.9 0.22 0.2 0.44 ...
##  $ v2x_egal     : num  0.45 0.71 0.9 0.93 0.68 0.63 0.93 0.21 0.4 0.71 ...
vdem=vdem[,c(2:6)]
modelo1=formula(v2x_polyarchy ~ v2x_partip + v2xdl_delib)
regre1=lm(modelo1,data = vdem)
summary(regre1)
## 
## Call:
## lm(formula = modelo1, data = vdem)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.40057 -0.09087  0.01627  0.10232  0.28177 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.09372    0.02819  -3.325  0.00108 ** 
## v2x_partip   0.63452    0.08093   7.840 4.13e-13 ***
## v2xdl_delib  0.47371    0.05525   8.573 5.03e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1322 on 176 degrees of freedom
## Multiple R-squared:  0.7468, Adjusted R-squared:  0.7439 
## F-statistic: 259.5 on 2 and 176 DF,  p-value: < 2.2e-16
modelo2=formula(v2x_polyarchy ~ v2x_partip + v2xdl_delib + v2x_egal)
regre2=lm(modelo2,data = vdem)
summary(regre2)
## 
## Call:
## lm(formula = modelo2, data = vdem)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.41695 -0.06750  0.02382  0.09205  0.23484 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.16732    0.02856  -5.858 2.27e-08 ***
## v2x_partip   0.56214    0.07496   7.499 3.09e-12 ***
## v2xdl_delib  0.29556    0.05866   5.038 1.16e-06 ***
## v2x_egal     0.36239    0.06069   5.971 1.28e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1208 on 175 degrees of freedom
## Multiple R-squared:  0.7896, Adjusted R-squared:  0.786 
## F-statistic: 218.9 on 3 and 175 DF,  p-value: < 2.2e-16
modelo3=formula(v2x_polyarchy ~ v2x_partip + v2xdl_delib + v2x_egal + v2x_liberal)
regre3=lm(modelo3,data = vdem)
summary(regre3)
## 
## Call:
## lm(formula = modelo3, data = vdem)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.27888 -0.06142  0.01883  0.06897  0.19187 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.09343    0.02400  -3.893 0.000141 ***
## v2x_partip   0.34928    0.06361   5.491 1.39e-07 ***
## v2xdl_delib -0.01623    0.05634  -0.288 0.773587    
## v2x_egal     0.12920    0.05385   2.399 0.017474 *  
## v2x_liberal  0.60183    0.06025   9.989  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.09657 on 174 degrees of freedom
## Multiple R-squared:  0.8663, Adjusted R-squared:  0.8632 
## F-statistic: 281.9 on 4 and 174 DF,  p-value: < 2.2e-16
modelo4=formula(v2x_polyarchy ~ v2x_partip + v2x_egal + v2x_liberal)
regre4=lm(modelo4,data = vdem)
summary(regre4)
## 
## Call:
## lm(formula = modelo4, data = vdem)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.28013 -0.06187  0.02162  0.06997  0.19258 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.09412    0.02382  -3.952 0.000112 ***
## v2x_partip   0.34483    0.06153   5.604 8.01e-08 ***
## v2x_egal     0.12701    0.05317   2.389 0.017960 *  
## v2x_liberal  0.59222    0.05002  11.839  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.09632 on 175 degrees of freedom
## Multiple R-squared:  0.8662, Adjusted R-squared:  0.8639 
## F-statistic: 377.8 on 3 and 175 DF,  p-value: < 2.2e-16

Rspta. a un nivel de significancia de 0.05, tiene efecto positivo y su magnitud es 0.562

Pregunta 2

Aplica un test de ANOVA y selecciona el mejor modelo:

La cuarta no puede ser anidada!

library(magrittr)
library(knitr)
tanova=anova(regre1, regre2, regre3)

kable(tanova,
      caption = "Tabla ANOVA para comparar modelos")%>%kableExtra::kable_styling(full_width = FALSE)
Tabla ANOVA para comparar modelos
Res.Df RSS Df Sum of Sq F Pr(>F)
176 3.073681 NA NA NA NA
175 2.553485 1 0.5201960 55.77649 0
174 1.622800 1 0.9306849 99.78995 0

Determinamos que la tercera es la mejor! ¿Pero cómo se compara a la cuarta hipótesis a esta?

Para ponerlo a prueba primero ubicaremos a la cuarta y luego a la tercera (la cuarta estaría anidada a la tercera, todas sus variables son parte de esta)

library(magrittr)
library(knitr)
tanova=anova(regre4, regre3)

kable(tanova,
      caption = "Tabla ANOVA para comparar modelos")%>%kableExtra::kable_styling(full_width = FALSE)
Tabla ANOVA para comparar modelos
Res.Df RSS Df Sum of Sq F Pr(>F)
175 1.623575 NA NA NA NA
174 1.622800 1 0.0007743 0.0830216 0.7735866

Efectivamente, el tercer modelo NO es mejor que el cuarto.

Rspta. Por esta razón, excepcionalmente, validaremos las respuestas de quienes indicaron:

Pregunta 3

Realiza el diagnóstico del cuarto modelo y responde lo siguiente:

plot(regre4, 1)

El modelo muestra homocedasticidad: * H0: el modelo es homocedastico * H1: el modelo no es homocedastico

Si p value es mayor a 0.05, entonces se acepta la hipótesis alternativa.

La afirmación es verdadera!

library(lmtest)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(kableExtra)
# null: modelo homocedastico
resBP=bptest(regre4)
data.frame(list('BP'=resBP$statistic,
             'df'=resBP$parameter,
             "p-value"=resBP$p.value))%>%
    kable(caption = resBP$method)%>%kable_styling(full_width = F)
studentized Breusch-Pagan test
BP df p.value
BP 4.271928 3 0.2335584

No hay normalidad en la distribución de los residuos del modelo

Si p value es menor a 0.05, entonces se rechaza la hipótesis nula.

La afirmación es verdadera!

#NULL: Datos se distribuyen de manera normal
resSW=shapiro.test(regre4$residuals)
data.frame(list('SW'=resSW$statistic,
             "p-value"=resSW$p.value))%>%
    kable(caption = resSW$method)%>%kable_styling(full_width = F)
Shapiro-Wilk normality test
SW p.value
W 0.961335 7.57e-05

La multicolinealidad de las variables no es preocupante

La afirmación es verdadera!

library(DescTools)
# > 5 es problematico
VIF(regre4) %>%kable(col.names = "VIF",caption ="Evaluando Multicolinealidad usando VIF (Variance Inflation Factors)" )%>%kable_styling(full_width = F)
Evaluando Multicolinealidad usando VIF (Variance Inflation Factors)
VIF
v2x_partip 2.408356
v2x_egal 2.593468
v2x_liberal 3.917741

No hay valores influyentes

La afirmación es verdadera!

library(kableExtra)
checkRegre4=as.data.frame(influence.measures(regre4)$is.inf)
checkRegre4[checkRegre4$cook.d & checkRegre4$hat,c('cook.d','hat')]%>%kable(caption = "Valores Influyentes criticos")%>%kable_styling(full_width = F)
Valores Influyentes criticos
cook.d hat
NA NA
:—— :—

Rspta. Ninguna de las anteriores.